Repository: airavata Updated Branches: refs/heads/master 82da3d2a7 -> 8d18255f3
fixing AIRAVATA-1467 Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/8d18255f Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/8d18255f Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/8d18255f Branch: refs/heads/master Commit: 8d18255f3858bfd39a7b3ac2e177560047701561 Parents: 82da3d2 Author: Chathuri Wimalasena <[email protected]> Authored: Fri Oct 17 11:37:53 2014 -0400 Committer: Chathuri Wimalasena <[email protected]> Committed: Fri Oct 17 11:37:53 2014 -0400 ---------------------------------------------------------------------- .../airavata/api/server/AiravataAPIServer.java | 167 +++++++++++++- .../airavata/api/server/WorkflowServer.java | 2 +- .../server/handler/AiravataServerHandler.java | 224 ++++++++----------- .../client/samples/CreateLaunchExperiment.java | 14 +- .../apache/airavata/common/utils/Constants.java | 7 + 5 files changed, 273 insertions(+), 141 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/8d18255f/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java index f0d303f..2dbe4c0 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/AiravataAPIServer.java @@ -21,14 +21,19 @@ package org.apache.airavata.api.server; +import java.io.File; +import java.io.IOException; import java.net.InetSocketAddress; +import java.util.Random; import org.apache.airavata.api.Airavata; import org.apache.airavata.api.server.handler.AiravataServerHandler; import org.apache.airavata.api.server.util.AppCatalogInitUtil; import org.apache.airavata.api.server.util.Constants; import org.apache.airavata.api.server.util.RegistryInitUtil; +import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.utils.AiravataUtils; +import org.apache.airavata.common.utils.AiravataZKUtils; import org.apache.airavata.common.utils.IServer; import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.model.error.AiravataErrorType; @@ -38,16 +43,19 @@ import org.apache.thrift.server.TThreadPoolServer; import org.apache.thrift.transport.TServerSocket; import org.apache.thrift.transport.TServerTransport; import org.apache.thrift.transport.TTransportException; +import org.apache.zookeeper.*; +import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AiravataAPIServer implements IServer{ +public class AiravataAPIServer implements IServer, Watcher{ private final static Logger logger = LoggerFactory.getLogger(AiravataAPIServer.class); private static final String SERVER_NAME = "Airavata API Server"; private static final String SERVER_VERSION = "1.0"; + private ZooKeeper zk; + private static Integer mutex = -1; - //FIXME: Read the port from airavata-server.config file private ServerStatus status; private TServer server; @@ -56,7 +64,7 @@ public class AiravataAPIServer implements IServer{ setStatus(ServerStatus.STOPPED); } - public void StartAiravataServer(Airavata.Processor<Airavata.Iface> airavataAPIServer) throws AiravataSystemException { + public void startAiravataServer(Airavata.Processor<Airavata.Iface> airavataAPIServer) throws AiravataSystemException { try { AiravataUtils.setExecutionAsServer(); RegistryInitUtil.initializeDB(); @@ -100,6 +108,7 @@ public class AiravataAPIServer implements IServer{ } } }.start(); + storeServerConfig(); } catch (TTransportException e) { logger.error(e.getMessage()); setStatus(ServerStatus.FAILED); @@ -108,6 +117,128 @@ public class AiravataAPIServer implements IServer{ } } + public void storeServerConfig() throws AiravataSystemException{ + try { + String zkhostPort = AiravataZKUtils.getZKhostPort(); + String airavataServerHostPort = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_HOST) + + ":" + ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_PORT); + String experimentCatalogJDBCURL = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.REGISTRY_JDBC_URL); + String appCatalogJDBCURL = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.APPCATALOG_JDBC_URL); + String rabbitMqBrokerURL = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.RABBITMQ_BROKER_URL); + String rabbitMqExchange = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.RABBITMQ_EXCHANGE); + String rabbitMq = rabbitMqBrokerURL + File.separator + rabbitMqExchange; + zk = new ZooKeeper(zkhostPort, 6000, this); // no watcher is required, this will only use to store some data + String apiServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_API_SERVER_NODE, "/airavata-server"); + String OrchServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_ORCHESTRATOR_SERVER_NODE, "/orchestrator-server"); + String gfacServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_SERVER_NODE, "/gfac-server"); + String gfacExperiments = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE, "/gfac-experiments"); + String experimentCatalog = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_EXPERIMENT_CATALOG, "/experiment-catalog"); + String appCatalog = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_APPCATALOG, "/app-catalog"); + String rabbitMQ = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_RABBITMQ, "/rabbitMq"); + Stat zkStat = zk.exists(experimentCatalog, false); + if (zkStat == null) { + zk.create(experimentCatalog, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + String exCatalogInstantNode = experimentCatalog + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(exCatalogInstantNode, false); + if (zkStat == null) { + zk.create(exCatalogInstantNode, + experimentCatalogJDBCURL.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created experiment-catalog node"); + } + zkStat = zk.exists(appCatalog, false); + if (zkStat == null) { + zk.create(appCatalog, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + String appCatalogInstantNode = appCatalog + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(appCatalogInstantNode, false); + if (zkStat == null) { + zk.create(appCatalogInstantNode, + appCatalogJDBCURL.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created app-catalog node"); + } + if (getStatus().equals(ServerStatus.STARTED)) { + zkStat = zk.exists(apiServer, false); + if (zkStat == null) { + zk.create(apiServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + String instantNode = apiServer + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(instantNode, false); + if (zkStat == null) { + zk.create(instantNode, + airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created airavata-server node"); + } + + zkStat = zk.exists(OrchServer, false); + if (zkStat == null) { + zk.create(OrchServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + logger.info("Successfully created orchestrator-server node"); + } + zkStat = zk.exists(gfacServer, false); + if (zkStat == null) { + zk.create(gfacServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + logger.info("Successfully created gfac-server node"); + } + zkStat = zk.exists(gfacServer, false); + if (zkStat == null) { + zk.create(gfacExperiments, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + logger.info("Successfully created gfac-server node"); + } + zkStat = zk.exists(rabbitMQ, false); + if (zkStat == null) { + zk.create(rabbitMQ, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.PERSISTENT); + } + if (ServerSettings.isRabbitMqPublishEnabled()) { + String rabbitMqInstantNode = rabbitMQ + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); + zkStat = zk.exists(rabbitMqInstantNode, false); + if (zkStat == null) { + zk.create(rabbitMqInstantNode, + rabbitMq.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, + CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node + logger.info("Successfully created rabbitMQ node"); + } + } + logger.info("Finished starting ZK: " + zk); + } + } catch (ApplicationSettingsException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (IOException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (KeeperException e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } catch (Exception e) { + logger.error(e.getMessage()); + setStatus(ServerStatus.FAILED); + RegistryInitUtil.stopDerbyInServerMode(); + throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR); + } + } + public static void main(String[] args) { try { AiravataAPIServer server = new AiravataAPIServer(); @@ -122,7 +253,7 @@ public class AiravataAPIServer implements IServer{ setStatus(ServerStatus.STARTING); Airavata.Processor<Airavata.Iface> airavataAPIServer = new Airavata.Processor<Airavata.Iface>(new AiravataServerHandler()); - StartAiravataServer(airavataAPIServer); + startAiravataServer(airavataAPIServer); } @Override @@ -166,4 +297,32 @@ public class AiravataAPIServer implements IServer{ return SERVER_VERSION; } + @Override + synchronized public void process(WatchedEvent watchedEvent) { + synchronized (mutex) { + Event.KeeperState state = watchedEvent.getState(); + logger.info(state.name()); + if (state == Event.KeeperState.SyncConnected) { + mutex.notify(); + } else if(state == Event.KeeperState.Expired || + state == Event.KeeperState.Disconnected){ + try { + mutex = -1; + zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), 6000, this); + synchronized (mutex) { + mutex.wait(); // waiting for the syncConnected event + } + storeServerConfig(); + } catch (IOException e) { + logger.error("Error while synchronizing with zookeeper", e); + } catch (ApplicationSettingsException e) { + logger.error("Error while synchronizing with zookeeper", e); + } catch (InterruptedException e) { + logger.error("Error while synchronizing with zookeeper", e); + } catch (AiravataSystemException e) { + logger.error("Error while synchronizing with zookeeper", e); + } + } + } + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/8d18255f/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/WorkflowServer.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/WorkflowServer.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/WorkflowServer.java index 34f3475..e9ce328 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/WorkflowServer.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/WorkflowServer.java @@ -58,7 +58,7 @@ public class WorkflowServer implements IServer{ public void StartAiravataServer(Workflow.Processor<Workflow.Iface> appCatalogServerHandler) throws AiravataSystemException { try { AiravataUtils.setExecutionAsServer(); - AppCatalogInitUtil.initializeDB(); +// AppCatalogInitUtil.initializeDB(); final int serverPort = Integer.parseInt(ServerSettings.getSetting(Constants.WORKFLOW_SERVER_PORT,"8931")); final String serverHost = ServerSettings.getSetting(Constants.WORKFLOW_SERVER_HOST, null); http://git-wip-us.apache.org/repos/asf/airavata/blob/8d18255f/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index a59f05e..30e4d26 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -21,31 +21,16 @@ package org.apache.airavata.api.server.handler; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import org.airavata.appcatalog.cpi.AppCatalog; -import org.airavata.appcatalog.cpi.AppCatalogException; -import org.airavata.appcatalog.cpi.ApplicationDeployment; -import org.airavata.appcatalog.cpi.ComputeResource; -import org.airavata.appcatalog.cpi.GwyResourceProfile; +import org.airavata.appcatalog.cpi.*; import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory; import org.apache.aiaravata.application.catalog.data.resources.*; import org.apache.aiaravata.application.catalog.data.util.AppCatalogThriftConversion; import org.apache.airavata.api.Airavata; import org.apache.airavata.api.airavataAPIConstants; import org.apache.airavata.api.server.util.DataModelUtils; -import org.apache.airavata.common.exception.ApplicationSettingsException; import org.apache.airavata.common.logger.AiravataLogger; import org.apache.airavata.common.logger.AiravataLoggerFactory; import org.apache.airavata.common.utils.AiravataUtils; -import org.apache.airavata.common.utils.AiravataZKUtils; import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription; import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule; @@ -55,12 +40,7 @@ import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; import org.apache.airavata.model.appcatalog.computeresource.*; import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; -import org.apache.airavata.model.error.AiravataClientException; -import org.apache.airavata.model.error.AiravataErrorType; -import org.apache.airavata.model.error.AiravataSystemException; -import org.apache.airavata.model.error.ExperimentNotFoundException; -import org.apache.airavata.model.error.InvalidRequestException; -import org.apache.airavata.model.error.ProjectNotFoundException; +import org.apache.airavata.model.error.*; import org.apache.airavata.model.util.ExecutionType; import org.apache.airavata.model.workspace.Project; import org.apache.airavata.model.workspace.experiment.*; @@ -69,11 +49,7 @@ import org.apache.airavata.orchestrator.cpi.OrchestratorService; import org.apache.airavata.orchestrator.cpi.OrchestratorService.Client; import org.apache.airavata.persistance.registry.jpa.ResourceUtils; import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; -import org.apache.airavata.registry.cpi.ChildDataType; -import org.apache.airavata.registry.cpi.ParentDataType; -import org.apache.airavata.registry.cpi.Registry; -import org.apache.airavata.registry.cpi.RegistryException; -import org.apache.airavata.registry.cpi.RegistryModelType; +import org.apache.airavata.registry.cpi.*; import org.apache.airavata.registry.cpi.utils.Constants; import org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.TaskDetailConstants; import org.apache.airavata.registry.cpi.utils.Constants.FieldConstants.WorkflowNodeConstants; @@ -81,113 +57,103 @@ import org.apache.airavata.workflow.engine.WorkflowEngine; import org.apache.airavata.workflow.engine.WorkflowEngineException; import org.apache.airavata.workflow.engine.WorkflowEngineFactory; import org.apache.thrift.TException; -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher; -import org.apache.zookeeper.ZooDefs; -import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.data.Stat; - -public class AiravataServerHandler implements Airavata.Iface, Watcher { + +import java.util.*; + +public class AiravataServerHandler implements Airavata.Iface { private static final AiravataLogger logger = AiravataLoggerFactory.getLogger(AiravataServerHandler.class); private Registry registry; private AppCatalog appCatalog; - private ZooKeeper zk; - - private static Integer mutex = -1; - - public AiravataServerHandler() { - try { - storeServerConfig(); - } catch (ApplicationSettingsException e) { - e.printStackTrace(); - } - } - - private void storeServerConfig() throws ApplicationSettingsException { - String zkhostPort = AiravataZKUtils.getZKhostPort(); - String airavataServerHostPort = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_HOST) - + ":" + ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_PORT); - - try { - zk = new ZooKeeper(zkhostPort, 6000, this); // no watcher is required, this will only use to store some data - String apiServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_API_SERVER_NODE,"/airavata-server"); - String OrchServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_ORCHESTRATOR_SERVER_NODE,"/orchestrator-server"); - String gfacServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_SERVER_NODE,"/gfac-server"); - String gfacExperiments = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE,"/gfac-experiments"); - - synchronized (mutex) { - mutex.wait(); // waiting for the syncConnected event - } - Stat zkStat = zk.exists(apiServer, false); - if (zkStat == null) { - zk.create(apiServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, - CreateMode.PERSISTENT); - } - String instantNode = apiServer + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); - zkStat = zk.exists(instantNode, false); - if (zkStat == null) { - zk.create(instantNode, - airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, - CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node - logger.info("Successfully created airavata-server node"); - } - - zkStat = zk.exists(OrchServer, false); - if (zkStat == null) { - zk.create(OrchServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, - CreateMode.PERSISTENT); - logger.info("Successfully created orchestrator-server node"); - } - zkStat = zk.exists(gfacServer, false); - if (zkStat == null) { - zk.create(gfacServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, - CreateMode.PERSISTENT); - logger.info("Successfully created gfac-server node"); - } - zkStat = zk.exists(gfacServer, false); - if (zkStat == null) { - zk.create(gfacExperiments, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, - CreateMode.PERSISTENT); - logger.info("Successfully created gfac-server node"); - } - logger.info("Finished starting ZK: " + zk); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (KeeperException e) { - e.printStackTrace(); - } - } - synchronized public void process(WatchedEvent watchedEvent) { - synchronized (mutex) { - Event.KeeperState state = watchedEvent.getState(); - logger.info(state.name()); - if (state == Event.KeeperState.SyncConnected) { - mutex.notify(); - } else if(state == Event.KeeperState.Expired || - state == Event.KeeperState.Disconnected){ - try { - mutex = -1; - zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), 6000, this); - synchronized (mutex) { - mutex.wait(); // waiting for the syncConnected event - } - storeServerConfig(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ApplicationSettingsException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } +// try { +// storeServerConfig(); +// } catch (ApplicationSettingsException e) { +// e.printStackTrace(); +// } + } + +// private void storeServerConfig() throws ApplicationSettingsException { +// String zkhostPort = AiravataZKUtils.getZKhostPort(); +// String airavataServerHostPort = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_HOST) +// + ":" + ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.API_SERVER_PORT); +// +// try { +// zk = new ZooKeeper(zkhostPort, 6000, this); // no watcher is required, this will only use to store some data +// String apiServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_API_SERVER_NODE,"/airavata-server"); +// String OrchServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_ORCHESTRATOR_SERVER_NODE,"/orchestrator-server"); +// String gfacServer = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_SERVER_NODE,"/gfac-server"); +// String gfacExperiments = ServerSettings.getSetting(org.apache.airavata.common.utils.Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE,"/gfac-experiments"); +// +// synchronized (mutex) { +// mutex.wait(); // waiting for the syncConnected event +// } +// Stat zkStat = zk.exists(apiServer, false); +// if (zkStat == null) { +// zk.create(apiServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, +// CreateMode.PERSISTENT); +// } +// String instantNode = apiServer + File.separator + String.valueOf(new Random().nextInt(Integer.MAX_VALUE)); +// zkStat = zk.exists(instantNode, false); +// if (zkStat == null) { +// zk.create(instantNode, +// airavataServerHostPort.getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, +// CreateMode.EPHEMERAL); // other component will watch these childeren creation deletion to monitor the status of the node +// logger.info("Successfully created airavata-server node"); +// } +// +// zkStat = zk.exists(OrchServer, false); +// if (zkStat == null) { +// zk.create(OrchServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, +// CreateMode.PERSISTENT); +// logger.info("Successfully created orchestrator-server node"); +// } +// zkStat = zk.exists(gfacServer, false); +// if (zkStat == null) { +// zk.create(gfacServer, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, +// CreateMode.PERSISTENT); +// logger.info("Successfully created gfac-server node"); +// } +// zkStat = zk.exists(gfacServer, false); +// if (zkStat == null) { +// zk.create(gfacExperiments, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, +// CreateMode.PERSISTENT); +// logger.info("Successfully created gfac-server node"); +// } +// logger.info("Finished starting ZK: " + zk); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } catch (KeeperException e) { +// e.printStackTrace(); +// } +// } +// synchronized public void process(WatchedEvent watchedEvent) { +// synchronized (mutex) { +// Event.KeeperState state = watchedEvent.getState(); +// logger.info(state.name()); +// if (state == Event.KeeperState.SyncConnected) { +// mutex.notify(); +// } else if(state == Event.KeeperState.Expired || +// state == Event.KeeperState.Disconnected){ +// try { +// mutex = -1; +// zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), 6000, this); +// synchronized (mutex) { +// mutex.wait(); // waiting for the syncConnected event +// } +// storeServerConfig(); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (ApplicationSettingsException e) { +// e.printStackTrace(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// } /** * Query Airavata to fetch the API version http://git-wip-us.apache.org/repos/asf/airavata/blob/8d18255f/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java index df73845..a843447 100644 --- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java +++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java @@ -46,9 +46,9 @@ public class CreateLaunchExperiment { private static final String DEFAULT_USER = "default.registry.user"; private static final String DEFAULT_GATEWAY = "default.registry.gateway"; private static Airavata.Client airavataClient; - private static String echoAppId = "Echo_9bc4ca80-632e-4d6e-8696-45268fce8732"; - private static String wrfAppId = "WRF_15ae6599-a48f-4134-95b8-98e109ac6f88"; - private static String amberAppId = "Amber_a7b18a3a-31b3-4dc7-8faf-7c3144f14201"; + private static String echoAppId = "Echo_5d4d04d6-6b21-44cd-9855-f27359bc28ac"; + private static String wrfAppId = "WRF_2e57b355-be91-47b7-a2f4-44a7dd9e8093"; + private static String amberAppId = "Amber_df55a92b-a3af-48d8-8976-72cac88c7257"; private static String localHost = "localhost"; private static String trestlesHostName = "trestles.sdsc.xsede.org"; @@ -60,7 +60,7 @@ public class CreateLaunchExperiment { airavataClient = AiravataClientFactory.createAiravataClient(THRIFT_SERVER_HOST, THRIFT_SERVER_PORT); System.out.println("API version is " + airavataClient.getAPIVersion()); // registerApplications(); // run this only the first time - for (int i = 0; i < 1; i++) { + for (int i = 0; i < 10; i++) { // final String expId = createExperimentForSSHHost(airavata); final String expId = createEchoExperimentForTrestles(airavataClient); // final String expId = createEchoExperimentForStampede(airavataClient); @@ -72,11 +72,11 @@ public class CreateLaunchExperiment { // final String expId = createExperimentForStampedeAmber(airavataClient); // final String expId = createExperimentForTrestlesAmber(airavataClient); -// System.out.println("Experiment ID : " + expId); + System.out.println("Experiment ID : " + expId); // updateExperiment(airavata, expId); launchExperiment(airavataClient, expId); - } - } catch (Exception e) { + } + } catch (Exception e) { logger.error("Error while connecting with server", e.getMessage()); e.printStackTrace(); } http://git-wip-us.apache.org/repos/asf/airavata/blob/8d18255f/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java ---------------------------------------------------------------------- diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java index 3a5fd4c..8fe5b6e 100644 --- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java +++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/Constants.java @@ -33,10 +33,17 @@ public final class Constants { public static final String PULL = "pull"; public static final String API_SERVER_PORT = "apiserver.server.port"; public static final String API_SERVER_HOST = "apiserver.server.host"; + public static final String REGISTRY_JDBC_URL = "registry.jdbc.url"; + public static final String APPCATALOG_JDBC_URL = "appcatalog.jdbc.url"; + public static final String RABBITMQ_BROKER_URL = "rabbitmq.broker.url"; + public static final String RABBITMQ_EXCHANGE = "rabbitmq.exchange.name"; public static final String ORCHESTRATOR_SERVER_HOST = "orchestrator.server.host"; public static final String ORCHESTRATOR_SERVER_PORT = "orchestrator.server.port"; public static final String GFAC_SERVER_HOST = "gfac.server.host"; public static final String GFAC_SERVER_PORT = "gfac.server.port"; + public static final String ZOOKEEPER_EXPERIMENT_CATALOG = "experiment-catalog"; + public static final String ZOOKEEPER_APPCATALOG = "app-catalog"; + public static final String ZOOKEEPER_RABBITMQ = "rabbit-mq"; public static final String ZOOKEEPER_SERVER_HOST = "zookeeper.server.host"; public static final String ZOOKEEPER_SERVER_PORT = "zookeeper.server.port"; public static final String ZOOKEEPER_API_SERVER_NODE = "airavata-server";
