diff options
author | 2017-04-16 14:17:52 +0000 | |
---|---|---|
committer | 2017-04-19 21:37:15 +0000 | |
commit | e3c3eb5012b02d87a8d7143be3c195e86c298461 (patch) | |
tree | 349ac19ea8f8682fc48df58a54f084c237061980 /dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org | |
parent | 1650c3b0dda805110cac90dcaab8288d6b607b43 (diff) |
[DCAE-15] Changes related to version 1.1
See Jira for details
Change-Id: I29280abce45f53e80adf675f48cf1e0fff9e2c0a
Signed-off-by: Carsten Lund <lund@research.att.com>
Diffstat (limited to 'dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org')
2 files changed, 267 insertions, 158 deletions
diff --git a/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/cdap/adaptor/tools/Generator.java b/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/cdap/adaptor/tools/Generator.java index 0174c12..c043f16 100644 --- a/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/cdap/adaptor/tools/Generator.java +++ b/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/cdap/adaptor/tools/Generator.java @@ -53,12 +53,13 @@ public class Generator { String dir = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix();
dir = "src/main/sirius-gen/" + dir.replace('.', '/');
ControllerModel m = ControllermodelFactory.eINSTANCE.createControllerModel();
- m.setTemplateDirectory("../../dcae-org.openecomp.ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
+ m.setTemplateDirectory("../../../ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
m.setPrefix("Dcae");
m.setPluginName(p.getNsURI());
m.setName("ControllerServiceCdapManager");
m.setTitle("ControllerServiceCdapManager");
ControllerGenerator g = new ControllerGenerator(o, m);
+ g.setVersion("ONAP-R2"); g.setEnableIRequestHandler(false);
g.setEnableISiriusPlugin(false);
g.addFactory("org.openecomp.ncomp.servers.cdap.CdapCdapFactory");
@@ -82,12 +83,13 @@ public class Generator { String dir = p.getNsURI().replaceAll(p.getNsPrefix()+'$',"") + "servers." + p.getNsPrefix();
dir= "src/main/sirius-gen/" + dir.replace('.', '/');
ControllerModel m = ControllermodelFactory.eINSTANCE.createControllerModel();
- m.setTemplateDirectory("../../dcae-org.openecomp.ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
+ m.setTemplateDirectory("../../../ncomp.sirius.manager/ncomp-sirius-manager-generator/src/main/templates");
m.setPrefix("Dcae");
m.setPluginName(p.getNsURI());
m.setName("CdapService");
m.setTitle("CdapService");
ControllerGenerator g = new ControllerGenerator(o,m);
+ g.setVersion("ONAP-R2"); g.setEnableIRequestHandler(false);
g.setEnableISiriusPlugin(true);
// EObject gui = ModelFactory.eINSTANCE.createGuiClientApi();
diff --git a/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/cdap/DcaeCdapServiceProvider.java b/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/cdap/DcaeCdapServiceProvider.java index 8e802e1..e89de5c 100644 --- a/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/cdap/DcaeCdapServiceProvider.java +++ b/dcae-controller-service-cdap/dcae-controller-service-cdap-adaptor/src/main/java/org/openecomp/dcae/controller/service/servers/cdap/DcaeCdapServiceProvider.java @@ -18,7 +18,7 @@ * limitations under the License. * ============LICENSE_END============================================ */ - + package org.openecomp.dcae.controller.service.servers.cdap; import java.util.ArrayList; @@ -41,14 +41,30 @@ import org.openecomp.dcae.controller.core.stream.DcaeStream; import org.openecomp.dcae.controller.core.stream.DmaapStream; import org.openecomp.dcae.controller.service.cdap.CdapApplication; import org.openecomp.dcae.controller.service.cdap.CdapArtifact; +import org.openecomp.dcae.controller.service.cdap.CdapCreateAppStep; +import org.openecomp.dcae.controller.service.cdap.CdapCreateAppWithConfigStep; +import org.openecomp.dcae.controller.service.cdap.CdapDeployAppStep; import org.openecomp.dcae.controller.service.cdap.CdapFactory; import org.openecomp.dcae.controller.service.cdap.CdapInternalApplicationConfiguration; +import org.openecomp.dcae.controller.service.cdap.CdapLoadArtifactStep; +import org.openecomp.dcae.controller.service.cdap.CdapLoadArtifactWithConfigStep; +import org.openecomp.dcae.controller.service.cdap.CdapResumeScheduleStep; import org.openecomp.dcae.controller.service.cdap.CdapService; import org.openecomp.dcae.controller.service.cdap.CdapServiceInstance; +import org.openecomp.dcae.controller.service.cdap.CdapStartAppStep; +import org.openecomp.dcae.controller.service.cdap.CdapStartFlowStep; +import org.openecomp.dcae.controller.service.cdap.CdapStartServiceStep; +import org.openecomp.dcae.controller.service.cdap.CdapStartWorkerStep; +import org.openecomp.dcae.controller.service.cdap.CdapStep; +import org.openecomp.dcae.controller.service.cdap.CdapStopAppStep; +import org.openecomp.dcae.controller.service.cdap.CdapStopFlowStep; +import org.openecomp.dcae.controller.service.cdap.CdapStopServiceStep; +import org.openecomp.dcae.controller.service.cdap.CdapStopWorkerStep; import org.openecomp.dcae.controller.service.cdap.cluster.servers.manager.DcaeCdapClusterManagerConsole; import org.openecomp.dcae.controller.service.cdap.cluster.servers.service.DcaeCdapClusterService; import org.openecomp.dcae.controller.service.cdap.cluster.servers.service.DcaeCdapClusterServiceProvider; import org.openecomp.dcae.controller.service.cdap.cluster.service.CdapClusterServiceInstance; +import org.openecomp.dcae.controller.service.vm.VirtualMachineService; import org.openecomp.ncomp.cdap.CdapEntityWithPreferences; import org.openecomp.ncomp.cdap.CdapKeyPair; import org.openecomp.ncomp.cdap.CdapNamespace; @@ -56,6 +72,7 @@ import org.openecomp.ncomp.core.DeploymentStatus; import org.openecomp.ncomp.core.NamedEntity; import org.openecomp.ncomp.sirius.manager.AbstractClient; import org.openecomp.ncomp.sirius.manager.BasicAdaptorProvider; +import org.openecomp.ncomp.sirius.manager.ISiriusProvider; import org.openecomp.ncomp.sirius.manager.ISiriusServer; import org.openecomp.ncomp.sirius.manager.JavaHttpClient; import org.openecomp.ncomp.sirius.manager.ManagementServer; @@ -88,42 +105,111 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { DcaeCdapClusterManagerConsole console = consoleCluster(i); // console.loadArtifact(i.getCdapNamespace().getName(), i.getName(), // i.getJarFile()); - try { - console.createNamespace(i.getCdapName()); - } catch (Exception e1) { - logger.warn("reusing existing namespace"); - } - try { - for (CdapArtifact a : i.getArtifacts()) { - if (a.getVersion() != null) - console.loadArtifact(i.getCdapName(), a.getName(), a.getJarFile(), a.getVersion()); - console.deployApp(i.getCdapName(), a.getJarFile()); + synchronized (i) { + try { + console.createNamespace(i.getCdapName()); + } catch (Exception e1) { + logger.warn("reusing existing namespace"); } - for (CdapApplication a : i.getApps()) { -// System.err.println("CDAP: start app 1"); - console.loadArtifact(i.getCdapName(), a.getArtifactName(), a.getJarFile(), a.getVersion()); -// System.err.println("CDAP: start app 2"); - if (a.getAppConfigFileContent() == null) - console.createApp(i.getCdapName(), a.getName(), a.getArtifactName(), a.getVersion(), "user"); - else - console.createAppWithConfig(i.getCdapName(), a.getName(), a.getArtifactName(), a.getVersion(), "user", - a.getAppConfigFileContent()); -// System.err.println("CDAP: start app 3"); - } - } catch (Exception e) { - logger.warn("unable to start CDAP app: " + ManagementServer.object2ref(i)); - e.printStackTrace(); - throw new RuntimeException("Unable to start CDAP app: " + ManagementServer.object2ref(i) + " " + e); + try { + for (CdapArtifact a : i.getArtifacts()) { + if (a.getVersion() != null) + console.loadArtifact(i.getCdapName(), a.getName(), a.getJarFile(), a.getVersion()); + console.deployApp(i.getCdapName(), a.getJarFile()); + } + for (CdapApplication a : i.getApps()) { + // System.err.println("CDAP: start app 1"); + console.loadArtifact(i.getCdapName(), a.getArtifactName(), a.getJarFile(), a.getVersion()); + // System.err.println("CDAP: start app 2"); + if (a.getAppConfigFileContent() == null) + console.createApp(i.getCdapName(), a.getName(), a.getArtifactName(), a.getVersion(), "user"); + else + console.createAppWithConfig(i.getCdapName(), a.getName(), a.getArtifactName(), a.getVersion(), + "user", a.getAppConfigFileContent()); + // System.err.println("CDAP: start app 3"); + } + doSteps(console, i, i.getDeploySteps()); + } catch (Exception e) { + logger.warn("unable to start CDAP app: " + ManagementServer.object2ref(i)); + e.printStackTrace(); + throw new RuntimeException("Unable to start CDAP app: " + ManagementServer.object2ref(i) + " " + e); + } + } o.pushManagerConfiguration(instanceName); } + private void doSteps(DcaeCdapClusterManagerConsole console, CdapServiceInstance i, EList<CdapStep> steps) { + for (CdapStep s : steps) { + if (s instanceof CdapLoadArtifactStep) { + CdapLoadArtifactStep s1 = (CdapLoadArtifactStep) s; + console.loadArtifact(i.getCdapName(), s1.getArtifactName(), s1.getJarfile(), s1.getVersion()); + } + if (s instanceof CdapLoadArtifactWithConfigStep) { + CdapLoadArtifactWithConfigStep s1 = (CdapLoadArtifactWithConfigStep) s; + console.loadArtifactWithConfig(i.getCdapName(), s1.getArtifactName(), s1.getJarfile(), s1.getVersion(), + s1.getConfig()); + } + if (s instanceof CdapDeployAppStep) { + CdapDeployAppStep s1 = (CdapDeployAppStep) s; + console.deployApp(i.getCdapName(), s1.getJarfile()); + } + if (s instanceof CdapCreateAppStep) { + CdapCreateAppStep s1 = (CdapCreateAppStep) s; + console.createApp(i.getCdapName(), s1.getAppId(), s1.getArtifactName(), s1.getVersion(), s1.getScope()); + } + if (s instanceof CdapCreateAppWithConfigStep) { + CdapCreateAppWithConfigStep s1 = (CdapCreateAppWithConfigStep) s; + console.createAppWithConfig(i.getCdapName(), s1.getAppId(), s1.getArtifactName(), s1.getVersion(), + s1.getScope(), s1.getAppConfig()); + } + if (s instanceof CdapStartAppStep) { + CdapStartAppStep s1 = (CdapStartAppStep) s; + console.startApp(i.getCdapName(), s1.getAppId()); + } + if (s instanceof CdapStartFlowStep) { + CdapStartFlowStep s1 = (CdapStartFlowStep) s; + console.startFlow(i.getCdapName(), s1.getAppId(), s1.getFlowId(), s1.getExtraArgs()); + } + if (s instanceof CdapStartWorkerStep) { + CdapStartWorkerStep s1 = (CdapStartWorkerStep) s; + console.startWorker(i.getCdapName(), s1.getAppId(), s1.getWorkerId(), s1.getExtraArgs()); + } + if (s instanceof CdapStartServiceStep) { + CdapStartServiceStep s1 = (CdapStartServiceStep) s; + console.startService(i.getCdapName(), s1.getAppId(), s1.getServiceId(), s1.getExtraArgs()); + } + if (s instanceof CdapStopAppStep) { + CdapStopAppStep s1 = (CdapStopAppStep) s; + console.stopApp(i.getCdapName(), s1.getAppId()); + } + if (s instanceof CdapStopFlowStep) { + CdapStopFlowStep s1 = (CdapStopFlowStep) s; + console.stopFlow(i.getCdapName(), s1.getAppId(), s1.getFlowId()); + } + if (s instanceof CdapStopWorkerStep) { + CdapStopWorkerStep s1 = (CdapStopWorkerStep) s; + console.stopWorker(i.getCdapName(), s1.getAppId(), s1.getWorkerId()); + } + if (s instanceof CdapStopServiceStep) { + CdapStopServiceStep s1 = (CdapStopServiceStep) s; + console.stopService(i.getCdapName(), s1.getAppId(), s1.getServiceId()); + } + if (s instanceof CdapResumeScheduleStep) { + CdapResumeScheduleStep s1 = (CdapResumeScheduleStep) s; + console.resumeSchedule(i.getCdapName(), s1.getAppId(), s1.getScheduleId()); + + } + } + } + public void undeploy(String instanceName) { CdapServiceInstance i = findInstance(instanceName); DcaeCdapClusterManagerConsole console = consoleCluster(i); if (i.getCdapName() == null) { i.setCdapName(cdapName(i)); } + doSteps(console, i, i.getUndeploySteps()); for (String f : i.getFlowNames()) { String[] a = f.split("\\."); if (a.length != 2) @@ -143,7 +229,7 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { } for (CdapArtifact a : i.getArtifacts()) { try { -// console.stopApp(i.getCdapName(), a.getName()); + // console.stopApp(i.getCdapName(), a.getName()); console.deleteApp(i.getCdapName(), a.getName()); if (a.getVersion() != null) { console.deleteArtifact(i.getCdapName(), a.getName(), a.getVersion()); @@ -161,121 +247,127 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { e.printStackTrace(); } } -// console.deleteNamespace(i.getCdapName()); + // console.deleteNamespace(i.getCdapName()); } public void pushManagerConfiguration(String instanceName) { CdapServiceInstance i = findInstance(instanceName); o.updateInstanceConfiguration(instanceName); DcaeCdapClusterManagerConsole console = consoleCluster(i); - for (CdapArtifact a : i.getArtifacts()) { - try { - console.stopApp(i.getCdapName(), a.getName()); - } catch (Exception e) { - e.printStackTrace(); + synchronized (i) { + for (CdapArtifact a : i.getArtifacts()) { + try { + console.stopApp(i.getCdapName(), a.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } - } - for (CdapApplication a : i.getApps()) { - try { - console.stopApp(i.getCdapName(), a.getName()); - } catch (Exception e) { - e.printStackTrace(); + for (CdapApplication a : i.getApps()) { + try { + console.stopApp(i.getCdapName(), a.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } - } - for (String f : i.getFlowNames()) { - String[] a = f.split("\\."); - if (a.length != 2) - throw new RuntimeException("Bad flow name: " + f); - try { - console.stopFlow(i.getCdapName(), a[0], a[1]); - } catch (Exception e) { - e.printStackTrace(); + for (String f : i.getFlowNames()) { + String[] a = f.split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad flow name: " + f); + try { + console.stopFlow(i.getCdapName(), a[0], a[1]); + } catch (Exception e) { + e.printStackTrace(); + } } - } - for (String w : i.getWorkerNames()) { - String[] a = w.split("\\."); - if (a.length != 2) - throw new RuntimeException("Bad worker name: " + w); - try { - console.stopWorker(i.getCdapName(), a[0], a[1]); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + for (String w : i.getWorkerNames()) { + String[] a = w.split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad worker name: " + w); + try { + console.stopWorker(i.getCdapName(), a[0], a[1]); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - } - for (String s : i.getServiceNames()) { - String[] a = s.split("\\."); - if (a.length != 2) - throw new RuntimeException("Bad service name: " + s); - try { - console.stopService(i.getCdapName(), a[0], a[1]); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + for (String s : i.getServiceNames()) { + String[] a = s.split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad service name: " + s); + try { + console.stopService(i.getCdapName(), a[0], a[1]); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - } - - console.setPreferencesNameSpace(i.getCdapName(), list2string(i.getCdapConfiguration().getPreferences())); - for (CdapEntityWithPreferences w : i.getCdapConfiguration().getWorkers()) { - if (w.getPreferences().size() == 0) - continue; - String[] a = w.getName().split("\\.");if (a.length != 2) - throw new RuntimeException("Bad worker name: " + w.getName()); - console.setPreferencesWorker(i.getCdapName(), list2string(w.getPreferences()),a[0],a[1]); - } - for (CdapEntityWithPreferences s : i.getCdapConfiguration().getServices()) { - if (s.getPreferences().size() == 0) - continue; - String[] a = s.getName().split("\\.");if (a.length != 2) - throw new RuntimeException("Bad service name: " + s.getName()); - console.setPreferencesService(i.getCdapName(), list2string(s.getPreferences()),a[0],a[1]); - } - for (CdapEntityWithPreferences f : i.getCdapConfiguration().getFlows()) { - if (f.getPreferences().size() == 0) - continue; - String[] a = f.getName().split("\\.");if (a.length != 2) - throw new RuntimeException("Bad flow name: " + f.getName()); - console.setPreferencesFlow(i.getCdapName(), list2string(f.getPreferences()), a[0],a[1]); - } - for (CdapEntityWithPreferences a : i.getCdapConfiguration().getApps()) { - if (a.getPreferences().size() == 0) - continue; - console.setPreferencesApp(i.getCdapName(), list2string(a.getPreferences()), a.getName()); - } - // TODO what should we do. ?? - for (String f : i.getFlowNames()) { - String[] a = f.split("\\."); - if (a.length != 2) - throw new RuntimeException("Bad flow name: " + f); - console.startFlow(i.getCdapName(), a[0], a[1], null); - } - for (String w : i.getWorkerNames()) { - String[] a = w.split("\\."); - if (a.length != 2) - throw new RuntimeException("Bad worker name: " + w); - console.startWorker(i.getCdapName(), a[0], a[1], null); - } - for (String s : i.getServiceNames()) { - String[] a = s.split("\\."); - if (a.length != 2) - throw new RuntimeException("Bad service name: " + s); - console.startService(i.getCdapName(), a[0], a[1], null); - } - for (CdapArtifact a : i.getArtifacts()) { - try { - console.startApp(i.getCdapName(), a.getName()); - } catch (Exception e) { - e.printStackTrace(); + doSteps(console, i, i.getPreConfigurationSteps()); + + console.setPreferencesNameSpace(i.getCdapName(), list2string(i.getCdapConfiguration().getPreferences())); + for (CdapEntityWithPreferences w : i.getCdapConfiguration().getWorkers()) { + if (w.getPreferences().size() == 0) + continue; + String[] a = w.getName().split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad worker name: " + w.getName()); + console.setPreferencesWorker(i.getCdapName(), list2string(w.getPreferences()), a[0], a[1]); } - } - for (CdapApplication a : i.getApps()) { - try { - console.startApp(i.getCdapName(), a.getName()); - } catch (Exception e) { - e.printStackTrace(); + for (CdapEntityWithPreferences s : i.getCdapConfiguration().getServices()) { + if (s.getPreferences().size() == 0) + continue; + String[] a = s.getName().split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad service name: " + s.getName()); + console.setPreferencesService(i.getCdapName(), list2string(s.getPreferences()), a[0], a[1]); + } + for (CdapEntityWithPreferences f : i.getCdapConfiguration().getFlows()) { + if (f.getPreferences().size() == 0) + continue; + String[] a = f.getName().split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad flow name: " + f.getName()); + console.setPreferencesFlow(i.getCdapName(), list2string(f.getPreferences()), a[0], a[1]); + } + for (CdapEntityWithPreferences a : i.getCdapConfiguration().getApps()) { + if (a.getPreferences().size() == 0) + continue; + console.setPreferencesApp(i.getCdapName(), list2string(a.getPreferences()), a.getName()); + } + doSteps(console, i, i.getPostConfigurationSteps()); + // TODO what should we do. ?? + for (String f : i.getFlowNames()) { + String[] a = f.split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad flow name: " + f); + console.startFlow(i.getCdapName(), a[0], a[1], null); + } + for (String w : i.getWorkerNames()) { + String[] a = w.split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad worker name: " + w); + console.startWorker(i.getCdapName(), a[0], a[1], null); + } + for (String s : i.getServiceNames()) { + String[] a = s.split("\\."); + if (a.length != 2) + throw new RuntimeException("Bad service name: " + s); + console.startService(i.getCdapName(), a[0], a[1], null); + } + for (CdapArtifact a : i.getArtifacts()) { + try { + console.startApp(i.getCdapName(), a.getName()); + } catch (Exception e) { + e.printStackTrace(); + } + } + for (CdapApplication a : i.getApps()) { + try { + console.startApp(i.getCdapName(), a.getName()); + } catch (Exception e) { + e.printStackTrace(); + } } } - } public void pollManagerConfiguration(String instanceName) { @@ -301,13 +393,13 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { public HealthTestResponse test(String instanceName) { CdapServiceInstance i = findInstance(instanceName); HealthTestResponse res = ServiceFactory.eINSTANCE.createHealthTestResponse(); - + // simple check. Verify that namespace exists in cluster. - + CdapClusterServiceInstance s = i.getClusterService(); if (s.getStatus() != DeploymentStatus.DEPLOYED) { res.setStatus(HealthTestStatus.YELLOW); - res.setMessageCode("Cluster not deployed"); + res.setMessageCode("Cluster not deployed"); return res; } if (s.getCluster() == null) { @@ -319,11 +411,11 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { res.setStatus(HealthTestStatus.RED); res.setMessageCode("No Namepace for instance"); return res; - } + } for (CdapNamespace n : s.getCluster().getNamespaces()) { if (i.getNamespace().equals(n.getName())) { res.setStatus(HealthTestStatus.GREEN); - return res; + return res; } } res.setStatus(HealthTestStatus.YELLOW); @@ -379,7 +471,7 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { } private String cdapName(CdapServiceInstance i) { -// String n = "dcae:" + o.getName() + ":" + i.getName(); + // String n = "dcae:" + o.getName() + ":" + i.getName(); // return n.replace("-", "X").replace(":", "Y"); return i.getNamespace(); // return "dcae"+ new Date().getTime(); @@ -390,8 +482,20 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { // need to assign the leader EList<DcaeBasicServer> l = instance.getServers(); instance.setLeaderServer(l.get(l.size() - 1)); - DcaeCdapClusterService service = (DcaeCdapClusterService) instance.getService(); - DcaeCdapClusterServiceProvider provider = service.getSomfProvider(); + if (instance.getCdapServiceServers().size() == 0) { + // no configuration use last server per default + instance.getCdapServiceServers().add(instance.getLeaderServer().getName()); + } + for (DcaeBasicServer s : l) { + if (!instance.getCdapServiceServers().contains(s.getName())) + continue; + if (s.getHealthTestStatus() != HealthTestStatus.GREEN) + continue; + instance.setLeaderServer(s); + } + VirtualMachineService service = instance.getService(); + DcaeCdapClusterServiceProvider provider = (DcaeCdapClusterServiceProvider) ((ISiriusProvider) service) + .getSiriusProvider(); AbstractClient c = provider.getClient(instance); return new DcaeCdapClusterManagerConsole(c); } @@ -408,18 +512,19 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { // dmaap.XX.dmaapPassword if (p.getName().startsWith("dmaap") && p.getName().endsWith("dmaapPassword")) { String pw = p.getValue(); - if (! pw.startsWith("rsa:")) { -// System.err.println("ZZZZZ: unencrypted pw: " + ManagementServer.object2ref(p)); + if (!pw.startsWith("rsa:")) { + // System.err.println("ZZZZZ: unencrypted pw: " + + // ManagementServer.object2ref(p)); } try { pw = JavaHttpClient.decryptPassword(pw); } catch (Exception e) { -// System.err.println("ZZZZZ: badly encrypted password: " + ManagementServer.object2ref(p)); + // System.err.println("ZZZZZ: badly encrypted password: " + + // ManagementServer.object2ref(p)); pw = "badly encrypted password"; } buf.append(p.getName()).append("=").append(pw); - } - else { + } else { String v = p.getValue(); if (v.startsWith("rsa:")) { try { @@ -443,7 +548,8 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { throw new RuntimeException("Unable to find instance: " + instanceName); } - private void updateConfigSimple(EObject root, EObject i, String destination, CdapInternalApplicationConfiguration a) { + private void updateConfigSimple(EObject root, EObject i, String destination, + CdapInternalApplicationConfiguration a) { if (i == null) return; for (EAttribute attr : i.eClass().getEAllAttributes()) { @@ -459,7 +565,7 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { if (anno == null) continue; String destination = anno.getDetails().get("destination"); -// System.err.println("AAAAA" + attr.getName() + " " + destination); + // System.err.println("AAAAA" + attr.getName() + " " + destination); add(root, i, attr, destination, appConfig); } for (EReference ref : i.eClass().getEAllContainments()) { @@ -473,10 +579,12 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { updateConfig(root, (EObject) i.eGet(ref), appConfig); } } -// System.err.println(ManagementServer.ecore2json(appConfig, 1000, null, true).toString(2)); + // System.err.println(ManagementServer.ecore2json(appConfig, 1000, null, + // true).toString(2)); } - private void add(EObject root, EObject i, EAttribute attr, String destination, CdapInternalApplicationConfiguration appConfig) { + private void add(EObject root, EObject i, EAttribute attr, String destination, + CdapInternalApplicationConfiguration appConfig) { // Make this more complex later if (i instanceof NamedEntity) { NamedEntity n = (NamedEntity) i; @@ -487,7 +595,7 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { String path1 = ManagementServer.object2ref(root); String path2 = ManagementServer.object2ref(i); String path = path2.replace("/", ".").substring(path1.length() + 1); - destination = destination.replace("${path}", path ); + destination = destination.replace("${path}", path); String[] a = destination.split(":"); if (a.length != 3) { throw new RuntimeException("Bad CDAP destination annotation: " + destination); @@ -511,7 +619,8 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { private org.openecomp.ncomp.cdap.CdapFactory f = org.openecomp.ncomp.cdap.CdapFactory.eINSTANCE; - private void add(EObject root, EList<CdapEntityWithPreferences> l, String name, String cdapKey, EObject i, EAttribute attr) { + private void add(EObject root, EList<CdapEntityWithPreferences> l, String name, String cdapKey, EObject i, + EAttribute attr) { CdapEntityWithPreferences p = null; for (CdapEntityWithPreferences p1 : l) { if (p1.getName().equals(name)) { @@ -524,7 +633,7 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { l.add(p); p.setName(name); } - add(root,p.getPreferences(), cdapKey, i, attr); + add(root, p.getPreferences(), cdapKey, i, attr); } private void add(EObject root, EList<CdapKeyPair> prefs, String cdapKey, EObject i, EAttribute attr) { @@ -537,15 +646,14 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { l2.add((String) ManagementServer.attr2jsonValue(0, o, attr.getEType())); } value = StringUtil.join(l2, ":"); - } - else + } else value = (String) ManagementServer.attr2jsonValue(0, i.eGet(attr), attr.getEType()); CdapKeyPair pair = f.createCdapKeyPair(); pair.setName(cdapKey); pair.setValue(value); prefs.add(pair); } - + public void start() { Thread t = new Thread("cdap service: " + o.getName()) { @@ -559,7 +667,7 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { Thread.sleep(60000); // sleep 60 seconds } catch (Exception e) { ManagementServerUtils.printStackTrace(e); - logger.fatal("vm service: " + o.getName() + " : " + e); + logger.fatal("cdap service: " + o.getName() + " : " + e); try { Thread.sleep(30000); } catch (InterruptedException e1) { @@ -573,15 +681,15 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { } public void updateDeploymentStatus() { -// System.out.println("CDAP updateDeploymentStatus 1: "); + System.out.println("CDAP updateDeploymentStatus 1: "); for (CdapServiceInstance instance : o.getInstances()) { // TODO Docker deployment status instance.setStatus(DeploymentStatus.UNDEPLOYED); -// System.out.println("CDAP updateDeploymentStatus 2: " + instance.getName() + " " + instance.getNamespace()); + System.out.println("CDAP updateDeploymentStatus 2: " + instance.getName() + " " + instance.getNamespace()); if (instance.getClusterService() == null) continue; for (CdapNamespace c : instance.getClusterService().getCluster().getNamespaces()) { -// System.out.println("CDAP updateDeploymentStatus 4: " + c.getName()); + System.out.println("CDAP updateDeploymentStatus 4: " + c.getName()); if (instance.getNamespace() != null && instance.getNamespace().equals(c.getName())) { instance.setStatus(DeploymentStatus.DEPLOYED); } @@ -589,5 +697,4 @@ public class DcaeCdapServiceProvider extends BasicAdaptorProvider { } } - } |