2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.openo.holmes.engine;
18 import io.dropwizard.setup.Environment;
19 import java.io.IOException;
20 import lombok.extern.slf4j.Slf4j;
21 import org.openo.dropwizard.ioc.bundle.IOCApplication;
22 import org.openo.holmes.common.api.entity.ServiceRegisterEntity;
23 import org.openo.holmes.common.config.MicroServiceConfig;
24 import org.openo.holmes.common.utils.MSBRegisterUtil;
27 public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
29 public static void main(String[] args) throws Exception {
30 new EngineDActiveApp().run(args);
34 public void run(EngineDAppConfig configuration, Environment environment) throws Exception {
35 super.run(configuration, environment);
38 new MSBRegisterUtil().register(initServiceEntity());
39 } catch (IOException e) {
40 log.warn("Micro service registry httpclient close failure", e);
44 private ServiceRegisterEntity initServiceEntity() {
45 ServiceRegisterEntity serviceRegisterEntity = new ServiceRegisterEntity();
46 serviceRegisterEntity.setServiceName("holmes-rule-mgmt");
47 serviceRegisterEntity.setProtocol("REST");
48 serviceRegisterEntity.setVersion("v1");
49 serviceRegisterEntity.setUrl("/openoapi/holmes-rule-mgmt/v1");
50 serviceRegisterEntity.setSingleNode(MicroServiceConfig.getServiceIp(), "9101", 0);
51 serviceRegisterEntity.setVisualRange("1");
52 return serviceRegisterEntity;