http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cloud/cloud-provisioning/src/test/java/org/apache/airavata/cloud/test/CloudIntfTest.java ---------------------------------------------------------------------- diff --git a/modules/cloud/cloud-provisioning/src/test/java/org/apache/airavata/cloud/test/CloudIntfTest.java b/modules/cloud/cloud-provisioning/src/test/java/org/apache/airavata/cloud/test/CloudIntfTest.java deleted file mode 100644 index a8e4bb4..0000000 --- a/modules/cloud/cloud-provisioning/src/test/java/org/apache/airavata/cloud/test/CloudIntfTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.airavata.cloud.test; - -import org.apache.airavata.cloud.intf.CloudInterface; -import org.apache.airavata.cloud.intf.impl.OpenstackIntfImpl; -import org.apache.airavata.cloud.util.Constants; -import org.junit.Ignore; -import org.junit.Test; -import org.openstack4j.model.compute.Keypair; -import org.openstack4j.model.compute.Server; -import org.openstack4j.model.network.Network; -import org.openstack4j.model.network.Router; -import org.openstack4j.model.network.RouterInterface; -import org.openstack4j.model.network.Subnet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.Properties; -import java.util.Scanner; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class CloudIntfTest { - - /** The properties. */ - private String propertiesFile = "test_data.properties"; - private Properties properties; - - // Initializing Logger - private Logger logger = LoggerFactory.getLogger(CloudIntfTest.class); - - public CloudIntfTest() { - try { - - InputStream inputStream = getClass().getClassLoader() - .getResourceAsStream(propertiesFile); - - if(inputStream != null) { - properties = new Properties(); - properties.load(inputStream); - } - else { - throw new FileNotFoundException("property file: " + propertiesFile + " not found!"); - } - - } - catch(Exception ex) { - ex.printStackTrace(); - // TODO: Check with the team on how to handle exceptions. - } - } - - /** - * Test that will create keypair, create server with keypair, delete server, delete keypair. - */ - @Test - @Ignore - public void jetstreamCreateDeleteServerTest() { - try { - CloudInterface cloudIntf = new OpenstackIntfImpl("jetstream_openrc.properties"); - // Sample data. This can be determined by the inputs from Airavata. - String imageId = properties.getProperty("jetstream_imageId"); - String flavorId = properties.getProperty("jetstream_flavorId"); - - // Delay in milliseconds used for waiting for server create and delete. - Integer delay = 30000; - - /* Create Keypair */ - String publicKeyFile = properties.getProperty("publicKeyFile"); - String keyPairName = "testKey"; - - Scanner fileScan = new Scanner(new FileInputStream(publicKeyFile)); - String publicKey = fileScan.nextLine(); - - Keypair kp = (Keypair) cloudIntf.getKeyPair(keyPairName); - if(kp == null) { - kp = (Keypair) cloudIntf.createKeyPair(keyPairName, publicKey); - } - - logger.info("Keypair created/ retrieved: " + kp.getFingerprint()); - - /* Create Server */ - Server newServer = (Server) cloudIntf.createServer("AiravataTest", imageId, flavorId, kp.getName()); - logger.info("Server Created: " + newServer.getId()); - - /* Wait 30 seconds until server is active */ - logger.info("Waiting for instance to go ACTIVE..."); - Thread.sleep(delay); - - /* Associate floating ip */ - cloudIntf.addFloatingIP(newServer.getId()); - - /* Delete Server */ - cloudIntf.deleteServer(newServer.getId()); - logger.info("Server deleted: " + newServer.getId()); - - /* Wait 30 seconds until server is terminated */ - logger.info("Waiting for instance to terminate..."); - Thread.sleep(delay); - - /* Delete Keypair */ - cloudIntf.deleteKeyPair(kp.getName()); - logger.info("Keypair deleted: " + kp.getName()); - - Server deleted = (Server) cloudIntf.getServer(newServer.getId()); - - assertTrue(newServer != null && deleted == null); - } - catch( Exception ex ) { - ex.printStackTrace(); - fail(); - } - } - - /** - * Jetstream create delete network test. - */ - @Test - @Ignore - public void jetstreamCreateDeleteNetworkTest() { - try { - CloudInterface cloudIntf = new OpenstackIntfImpl("jetstream_openrc.properties"); - - /* fetch sample data from properties file */ - String networkName = properties.getProperty("jetstream_network_name"); - String subnetCIDR = properties.getProperty("jetstream_subnet_cidr"); - Integer ipVersion = Integer.valueOf(properties.getProperty("jetstream_ip_version", - Constants.OS_IP_VERSION_DEFAULT.toString())); - String externalGateway = properties.getProperty("jetstream_public_network_name"); - - /* build router and subnet names */ - String subnetName = "subnet-" + networkName; - String routerName = "router-" + networkName; - - /* create network */ - logger.info("Creating network with name = " + networkName); - Network network = (Network) cloudIntf.createNetwork(networkName); - assertTrue(network != null && network.getName().equals(networkName)); - - /* create subnet for network */ - logger.info("Creating subnet with name = " + subnetName + ", and CIDR = " + subnetCIDR + ", and version = " + ipVersion); - Subnet subnet = (Subnet) cloudIntf.createSubnet(subnetName, networkName, subnetCIDR, ipVersion); - assertTrue(subnet != null - && subnet.getName().equals(subnetName) - && subnet.getCidr().equals(subnetCIDR) - && subnet.getIpVersion().getVersion() == ipVersion.intValue()); - - /* create router for external gateway */ - logger.info("Creating router with name = " + routerName + ", and external gateway = " + externalGateway); - Router router = (Router) cloudIntf.createRouter(routerName, externalGateway); - assertTrue(router != null && router.getName().equals(routerName)); - - /* create router-subnet interface */ - logger.info("Creating interface between router = " + routerName + ", and subnet = " + subnetName); - RouterInterface iface = (RouterInterface) cloudIntf.createRouterSubnetInterface(routerName, subnetName); - assertTrue(iface != null && iface.getSubnetId().equals(subnet.getId())); - - /* delete router-subnet interface */ - logger.info("Deleting interface between router = " + routerName + ", and subnet = " + subnetName); - cloudIntf.deleteRouterSubnetInterface(routerName, subnetName); - - /* delete router for external gateway */ - logger.info("Creating router with name = " + routerName); - cloudIntf.deleteRouter(routerName); - - /* delete subnet for network */ - logger.info("Creating subnet with name = " + subnetName); - cloudIntf.deleteSubnet(subnetName); - - /* delete network */ - logger.info("Deleting network with name = " + networkName); - cloudIntf.deleteNetwork(networkName); - } catch( Exception ex ) { - ex.printStackTrace(); - fail(); - } - - } -}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cloud/cloud-provisioning/src/test/resources/test_data.properties ---------------------------------------------------------------------- diff --git a/modules/cloud/cloud-provisioning/src/test/resources/test_data.properties b/modules/cloud/cloud-provisioning/src/test/resources/test_data.properties deleted file mode 100644 index b5ded31..0000000 --- a/modules/cloud/cloud-provisioning/src/test/resources/test_data.properties +++ /dev/null @@ -1,32 +0,0 @@ -# -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Common properties -publicKeyFile=/path/id_rsa.pub - -# Jetstream properties -jetstream_imageId=7048bb41-bbbbb-4caa-9370-xxxxxxxxxxx -jetstream_flavorId=3 - -# Jetstream network related data -jetstream_network_name=test-network -jetstream_public_network_name=public -jetstream_subnet_cidr=192.168.7.0/24 -jetstream_ip_version=4 http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cloud/pom.xml ---------------------------------------------------------------------- diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml deleted file mode 100644 index 48f959f..0000000 --- a/modules/cloud/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <parent> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata</artifactId> - <version>0.17-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>airavata-cloud</artifactId> - <packaging>pom</packaging> - <name>Airavata Cloud</name> - <url>http://airavata.apache.org/</url> - - <modules> - <module>cloud-provisioning</module> - <module>aurora-client</module> - </modules> - <build> - <plugins> - <plugin> - <groupId>com.mycila</groupId> - <artifactId>license-maven-plugin</artifactId> - <version>3.0.rc1</version> - <configuration> - <header>../../apache-license-header.txt</header> - <excludes> - <exclude>**/README</exclude> - <exclude>src/test/resources/**</exclude> - <exclude>src/main/resources/**</exclude> - </excludes> - </configuration> - <executions> - <execution> - <phase>process-sources</phase> - <goals> - <goal>format</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cloud/src/main/java/org/apache/airavata/cloud/CloudMain.java ---------------------------------------------------------------------- diff --git a/modules/cloud/src/main/java/org/apache/airavata/cloud/CloudMain.java b/modules/cloud/src/main/java/org/apache/airavata/cloud/CloudMain.java deleted file mode 100644 index f9ff11b..0000000 --- a/modules/cloud/src/main/java/org/apache/airavata/cloud/CloudMain.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.airavata.cloud; - -public class CloudMain { - - public static void main(String[] args) { - System.out.println("Welcome to Airavata Cloud !!!"); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cluster-monitoring/pom.xml ---------------------------------------------------------------------- diff --git a/modules/cluster-monitoring/pom.xml b/modules/cluster-monitoring/pom.xml deleted file mode 100644 index 3da16b3..0000000 --- a/modules/cluster-monitoring/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>airavata</artifactId> - <groupId>org.apache.airavata</groupId> - <version>0.17-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>cluster-monitoring</artifactId> - - <dependencies> - <dependency> - <artifactId>airavata-data-models</artifactId> - <groupId>org.apache.airavata</groupId> - <version>${project.version}</version> - </dependency> - <dependency> - <artifactId>airavata-server-configuration</artifactId> - <groupId>org.apache.airavata</groupId> - <version>${project.version}</version> - </dependency> - <dependency> - <artifactId>airavata-credential-store</artifactId> - <groupId>org.apache.airavata</groupId> - <version>${project.version}</version> - </dependency> - <dependency> - <artifactId>registry-api-stubs</artifactId> - <groupId>org.apache.airavata</groupId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.quartz-scheduler</groupId> - <artifactId>quartz</artifactId> - <version>2.2.1</version> - </dependency> - <dependency> - <groupId>org.quartz-scheduler</groupId> - <artifactId>quartz-jobs</artifactId> - <version>2.2.1</version> - </dependency> - <dependency> - <groupId>com.jcraft</groupId> - <artifactId>jsch</artifactId> - <version>0.1.50</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.3.1</version> - </dependency> - </dependencies> - - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJob.java ---------------------------------------------------------------------- diff --git a/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJob.java b/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJob.java deleted file mode 100644 index 0ba8d80..0000000 --- a/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJob.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.cluster.monitoring; - -import com.jcraft.jsch.Channel; -import com.jcraft.jsch.ChannelExec; -import com.jcraft.jsch.JSch; -import com.jcraft.jsch.Session; -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.airavata.credential.store.cpi.CredentialStoreService; -import org.apache.airavata.credential.store.datamodel.SSHCredential; -import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription; -import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionInterface; -import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol; -import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; -import org.apache.airavata.model.status.QueueStatusModel; -import org.apache.airavata.registry.api.RegistryService; -import org.apache.thrift.TException; -import org.apache.thrift.protocol.TBinaryProtocol; -import org.apache.thrift.protocol.TProtocol; -import org.apache.thrift.transport.TSocket; -import org.apache.thrift.transport.TTransport; -import org.apache.thrift.transport.TTransportException; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class ClusterStatusMonitorJob implements Job { - private final static Logger logger = LoggerFactory.getLogger(ClusterStatusMonitorJob.class); - - - @Override - public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { - try{ - String superTenantGatewayId = ServerSettings.getSuperTenantGatewayId(); - RegistryService.Client registryClient = getRegistryClient(); - List<ComputeResourceProfile> computeResourceProfiles = new ArrayList<>(); - List<ComputeResourcePreference> computeResourcePreferences = registryClient.getAllGatewayComputeResourcePreferences(superTenantGatewayId); - if (computeResourcePreferences != null && computeResourcePreferences.size() > 0) { - computeResourcePreferences.stream().forEach(p -> { - try { - String computeResourceId = p.getComputeResourceId(); - String credentialStoreToken = p.getResourceSpecificCredentialStoreToken(); - String loginUserName = p.getLoginUserName(); - String hostName = null; - if (credentialStoreToken == null || credentialStoreToken.equals("")) { - credentialStoreToken = registryClient.getGatewayResourceProfile(superTenantGatewayId).getCredentialStoreToken(); - } - int port = -1; - ArrayList queueNames = new ArrayList<>(); - - ComputeResourceDescription computeResourceDescription = registryClient.getComputeResource(computeResourceId); - hostName = computeResourceDescription.getHostName(); - //FIXME This should come from compute resource description - port = 22; - computeResourceDescription.getBatchQueues().stream().forEach(q -> { - queueNames.add(q.getQueueName()); - }); - - List<JobSubmissionInterface> jobSubmissionInterfaces = computeResourceDescription.getJobSubmissionInterfaces(); - if (jobSubmissionInterfaces != null && jobSubmissionInterfaces.size() > 0) { - if (jobSubmissionInterfaces.get(0).getJobSubmissionProtocol().equals(JobSubmissionProtocol.SSH)) { - String resourceManagerType = registryClient.getSSHJobSubmission(jobSubmissionInterfaces.get(0) - .getJobSubmissionInterfaceId()).getResourceJobManager().getResourceJobManagerType().name(); - ComputeResourceProfile computeResourceProfile = new ComputeResourceProfile(hostName, - loginUserName, port, credentialStoreToken, queueNames, resourceManagerType); - computeResourceProfiles.add(computeResourceProfile); - } - } - } catch (TException e) { - logger.error(e.getMessage()); - } - }); - } - - ArrayList<QueueStatusModel> queueStatuses = new ArrayList<>(); - - for (ComputeResourceProfile computeResourceProfile : computeResourceProfiles) { - - String userName = computeResourceProfile.getUserName(); - String hostName = computeResourceProfile.getHostName(); - int port = computeResourceProfile.getPort(); - - try { - JSch jsch = new JSch(); - CredentialStoreService.Client credentialClient = getCredentialStoreClient(); - SSHCredential sshCredential = credentialClient.getSSHCredential(computeResourceProfile.getCredentialStoreToken(), superTenantGatewayId); - jsch.addIdentity(hostName, sshCredential.getPrivateKey().getBytes(), sshCredential.getPublicKey().getBytes(), sshCredential.getPassphrase().getBytes()); - - Session session = jsch.getSession(userName, hostName, port); - java.util.Properties config = new java.util.Properties(); - config.put("StrictHostKeyChecking", "no"); - session.setConfig(config); - - logger.debug("Connected to " + hostName); - - session.connect(); - for (String queue : computeResourceProfile.getQueueNames()) { - String command = ""; - if (computeResourceProfile.getResourceManagerType().equals("SLURM")) - command = "sinfo -s -p " + queue + " -o \"%a %F\" | tail -1"; - else if (computeResourceProfile.getResourceManagerType().equals("PBS")) - command = "qstat -Q " + queue + "| tail -1"; - - if (command.equals("")) { - logger.warn("No matching resource manager type found for " + computeResourceProfile.getResourceManagerType()); - continue; - } - - Channel channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(command); - channel.setInputStream(null); - ((ChannelExec) channel).setErrStream(System.err); - InputStream in = channel.getInputStream(); - channel.connect(); - byte[] tmp = new byte[1024]; - String result = ""; - while (true) { - while (in.available() > 0) { - int i = in.read(tmp, 0, 1024); - if (i < 0) break; - result += new String(tmp, 0, i); - } - if (channel.isClosed()) { - if (in.available() > 0) continue; - logger.debug(hostName + " " + queue + " " + "exit-status: " + channel.getExitStatus()); - break; - } - try { - Thread.sleep(1000); - } catch (Exception ee) { - } - } - channel.disconnect(); - - if (result != null && result.length() > 0) { - QueueStatusModel queueStatus = null; - if (computeResourceProfile.getResourceManagerType().equals("SLURM")) { - String[] sparts = result.split(" "); - boolean isUp = sparts[0].equalsIgnoreCase("up"); - String knts = sparts[1]; - sparts = knts.split("/"); - int running = Integer.parseInt(sparts[0].trim()); - int queued = Integer.parseInt(sparts[1].trim()); - queueStatus = new QueueStatusModel(hostName, queue, isUp, running, queued, System.currentTimeMillis()); - - } else if (computeResourceProfile.getResourceManagerType().equals("PBS")) { - result = result.replaceAll("\\s+", " "); - String[] sparts = result.split(" "); - boolean isUp = sparts[3].equalsIgnoreCase("yes"); - int running = Integer.parseInt(sparts[6].trim()); - int queued = Integer.parseInt(sparts[5].trim()); - queueStatus = new QueueStatusModel(hostName, queue, isUp, running, queued, System.currentTimeMillis()); - } - - if (queueStatus != null) - queueStatuses.add(queueStatus); - } - } - session.disconnect(); - } catch (Exception ex) { - logger.error("Failed to get cluster status from " + computeResourceProfile.getHostName()); - logger.error(ex.getMessage(), ex); - } - } - - registryClient.registerQueueStatuses(queueStatuses); - }catch (Exception e){ - throw new JobExecutionException(e); - } - - } - private static RegistryService.Client getRegistryClient() throws TTransportException, ApplicationSettingsException { - TTransport transport = new TSocket(ServerSettings.getRegistryServerHost(), Integer.parseInt(ServerSettings.getRegistryServerPort())); - transport.open(); - TProtocol protocol = new TBinaryProtocol(transport); - RegistryService.Client registryClient = new RegistryService.Client(protocol); - return registryClient; - } - - private static CredentialStoreService.Client getCredentialStoreClient() throws TTransportException, ApplicationSettingsException { - TTransport transport = new TSocket(ServerSettings.getCredentialStoreServerHost(), Integer.parseInt(ServerSettings.getCredentialStoreServerPort())); - transport.open(); - TProtocol protocol = new TBinaryProtocol(transport); - CredentialStoreService.Client credentialServiceClient = new CredentialStoreService.Client(protocol); - return credentialServiceClient; - } - - private static class ComputeResourceProfile { - - private String hostName; - private String userName; - private int port; - private String credentialStoreToken; - private List<String> queueNames; - private String resourceManagerType; - - public ComputeResourceProfile(String hostName, String userName, int port, String credentialStoreToken, List<String> queueNames, String resourceManagerType) { - this.hostName = hostName; - this.userName = userName; - this.port = port; - this.credentialStoreToken = credentialStoreToken; - this.queueNames = queueNames; - this.resourceManagerType = resourceManagerType; - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getCredentialStoreToken() { - return credentialStoreToken; - } - - public void setCredentialStoreToken(String credentialStoreToken) { - this.credentialStoreToken = credentialStoreToken; - } - - public List<String> getQueueNames() { - return queueNames; - } - - public void setQueueNames(List<String> queueNames) { - this.queueNames = queueNames; - } - - public String getResourceManagerType() { - return resourceManagerType; - } - - public void setResourceManagerType(String resourceManagerType) { - this.resourceManagerType = resourceManagerType; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJobScheduler.java ---------------------------------------------------------------------- diff --git a/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJobScheduler.java b/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJobScheduler.java deleted file mode 100644 index 88e76c4..0000000 --- a/modules/cluster-monitoring/src/main/java/org/apache/airavata/cluster/monitoring/ClusterStatusMonitorJobScheduler.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.cluster.monitoring; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.airavata.common.utils.ServerSettings; -import org.quartz.*; -import org.quartz.impl.StdSchedulerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.quartz.Scheduler; -import org.quartz.SchedulerException; - -import static org.quartz.JobBuilder.newJob; -import static org.quartz.TriggerBuilder.*; -import static org.quartz.SimpleScheduleBuilder.*; - -public class ClusterStatusMonitorJobScheduler { - private final static Logger logger = LoggerFactory.getLogger(ClusterStatusMonitorJobScheduler.class); - - Scheduler scheduler; - - public ClusterStatusMonitorJobScheduler() throws SchedulerException { - scheduler = StdSchedulerFactory.getDefaultScheduler(); - scheduler.start(); - } - - public void scheduleClusterStatusMonitoring() throws SchedulerException, ApplicationSettingsException { - // define the job and tie it to our MyJob class - JobDetail job = newJob(ClusterStatusMonitorJob.class) - .withIdentity("cluster-status-monitoring", "airavata") - .build(); - - // Trigger the job to run now, and then repeat every 40 seconds - Trigger trigger = newTrigger() - .withIdentity("cluster-status-monitoring-trigger", "airavata") - .startNow() - .withSchedule(simpleSchedule() - .withIntervalInSeconds(Integer.parseInt(ServerSettings.getClusterStatusMonitoringRepatTime())) - .repeatForever()) - .build(); - - // Tell quartz to schedule the job using our trigger - scheduler.scheduleJob(job, trigger); - } - - public static void main(String[] args) throws SchedulerException, ApplicationSettingsException { - ClusterStatusMonitorJobScheduler jobScheduler = new ClusterStatusMonitorJobScheduler(); - jobScheduler.scheduleClusterStatusMonitoring(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/pom.xml ---------------------------------------------------------------------- diff --git a/modules/commons/pom.xml b/modules/commons/pom.xml deleted file mode 100644 index b204e48..0000000 --- a/modules/commons/pom.xml +++ /dev/null @@ -1,140 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!--Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file - distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under - the Apache License, Version 2.0 (theà "License"); you may not use this file except in compliance with the License. You may - obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to - in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF - ANY ~ KIND, either express or implied. See the License for the specific language governing permissions and limitations under - the License. --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <parent> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata</artifactId> - <version>0.17-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>airavata-commons</artifactId> - <packaging>jar</packaging> - <name>Airavata Commons</name> - <url>http://airavata.apache.org/</url> - - <dependencies> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-model-utils</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.ogce</groupId> - <artifactId>xpp3</artifactId> - <version>${xpp3.version}</version> - </dependency> - <dependency> - <groupId>org.ogce</groupId> - <artifactId>xpp5</artifactId> - <version>${xpp5.version}</version> - </dependency> - <dependency> - <groupId>commons-dbcp</groupId> - <artifactId>commons-dbcp</artifactId> - <version>1.4</version> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>12.0</version> - </dependency> - - <!-- Logging --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.derby</groupId> - <artifactId>derby</artifactId> - <version>${derby.version}</version> - </dependency> - <dependency> - <groupId>org.apache.derby</groupId> - <artifactId>derbyclient</artifactId> - <version>${derby.version}</version> - </dependency> - <dependency> - <groupId>org.apache.derby</groupId> - <artifactId>derbynet</artifactId> - <version>${derby.version}</version> - </dependency> - <dependency> - <groupId>org.apache.derby</groupId> - <artifactId>derbytools</artifactId> - <version>${derby.version}</version> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-core</artifactId> - <version>7.0.22</version> - </dependency> - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - <version>1.2</version> - </dependency> - <!-- Testing --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata-server-configuration</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - <dependency> - <groupId>org.apache.curator</groupId> - <artifactId>curator-framework</artifactId> - <version>${curator.version}</version> - </dependency> - <dependency> - <groupId>org.apache.thrift</groupId> - <artifactId>libthrift</artifactId> - <version>${thrift.version}</version> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>${google.gson.version}</version> - </dependency> - <dependency> - <groupId>org.apache.kafka</groupId> - <artifactId>kafka-clients</artifactId> - <version>${kafka-clients.version}</version> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <version>${logback.version}</version> - </dependency> - </dependencies> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - </properties> -</project> http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java b/modules/commons/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java deleted file mode 100644 index 8cf5ddf..0000000 --- a/modules/commons/src/main/java-templates/org/apache/airavata/common/utils/BuildConstant.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.utils; - -public class BuildConstant { - public static final String VERSION = "${git-describe}"; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java b/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java deleted file mode 100644 index 724d3a3..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/context/RequestContext.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.context; - -/** - * The request context class. This will be local to a thread. User data that needs to propagate relevant to a request - * will be stored here. We use thread local globals to store request data. Currently we only store user identity. - */ -public class RequestContext { - - public String getUserIdentity() { - return userIdentity; - } - - public void setUserIdentity(String userIdentity) { - this.userIdentity = userIdentity; - } - - /** - * User associated with current request. - */ - private String userIdentity; - - public String getGatewayId() { - return gatewayId; - } - - public void setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - } - - /** - * The gateway id. - */ - private String gatewayId; - -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java b/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java deleted file mode 100644 index 59142e4..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/context/WorkflowContext.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.context; - -/** - * The workflow context class. This will be local to a thread. Workflow data that needs to propagate relevant to a - * request will be stored here. We use thread local globals to store request data. Currently we only store user - * identity. - */ -public class WorkflowContext { - - private static final ThreadLocal userThreadLocal = new InheritableThreadLocal(); - - /** - * Sets the context. - * - * @param context - * The context to be set. - Careful when calling this. Make sure other data relevant to context is - * preserved. - */ - public static void set(RequestContext context) { - userThreadLocal.set(context); - } - - /** - * Clears the context - */ - public static void unset() { - userThreadLocal.remove(); - } - - /** - * Gets the context associated with current context. - * - * @return The context associated with current thread. - */ - public static RequestContext get() { - return (RequestContext) userThreadLocal.get(); - } - - /** - * Gets the user associated with current user. - * - * @return User id associated with current request. - */ - public static synchronized String getRequestUser() { - - RequestContext requestContext = (RequestContext) userThreadLocal.get(); - - if (requestContext != null) { - return requestContext.getUserIdentity(); - } - - return null; - } - - public static synchronized String getGatewayId() { - - RequestContext requestContext = (RequestContext) userThreadLocal.get(); - - if (requestContext != null) { - return requestContext.getGatewayId(); - } - - return null; - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java deleted file mode 100644 index 874e029..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataConfigurationException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.exception; - -public class AiravataConfigurationException extends AiravataException { - private static final long serialVersionUID = -9124231436834631249L; - - public AiravataConfigurationException() { - } - - public AiravataConfigurationException(String message){ - this(message, null); - } - - public AiravataConfigurationException(String message, Throwable e){ - super(message,e); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java deleted file mode 100644 index a41b77d..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.exception; - -public class AiravataException extends Exception { - - private static final long serialVersionUID = -5665822765183116821L; - public AiravataException() { - } - - public AiravataException(String message, Throwable e) { - super(message,e); - } - - public AiravataException(String message) { - super(message); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataStartupException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataStartupException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataStartupException.java deleted file mode 100644 index 2ec9f5a..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/exception/AiravataStartupException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.exception; - -public class AiravataStartupException extends Exception { - private static final long serialVersionUID = 495204868100143133L; - - public AiravataStartupException() { - super(); - } - - public AiravataStartupException(String message) { - super(message); - } - - public AiravataStartupException(String message, Throwable cause) { - super(message, cause); - } - - public AiravataStartupException(Throwable cause) { - super(cause); - } - - protected AiravataStartupException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java b/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java deleted file mode 100644 index b669fe0..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/exception/ApplicationSettingsException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.exception; - -public class ApplicationSettingsException extends AiravataException { - - private static final long serialVersionUID = -4901850535475160411L; - - public ApplicationSettingsException(String message) { - super(message); - } - - public ApplicationSettingsException(String message, Throwable e) { - super(message, e); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/logging/Exception.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logging/Exception.java b/modules/commons/src/main/java/org/apache/airavata/common/logging/Exception.java deleted file mode 100644 index cea0c95..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/logging/Exception.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.common.logging; - - -public class Exception { - - private String message; - - private String[] stackTrace; - - private String className; - - public Exception(String message, String[] stackTrace) { - this.message = message; - this.stackTrace = stackTrace; - } - - public Exception(String message, String[] stackTrace, String className) { - this.message = message; - this.stackTrace = stackTrace; - this.className = className; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String[] getStackTrace() { - return stackTrace; - } - - public void setStackTrace(String[] stackTrace) { - this.stackTrace = stackTrace; - } - - public String getClassName() { - return className; - } - - public void setClassName(String className) { - this.className = className; - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/logging/LogEntry.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logging/LogEntry.java b/modules/commons/src/main/java/org/apache/airavata/common/logging/LogEntry.java deleted file mode 100644 index 72fc4a0..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/logging/LogEntry.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.common.logging; - - -import java.lang.*; -import java.util.Map; - -public class LogEntry { - - private ServerId serverId; - - private String message; - - private String timestamp; - - private String level; - - private String loggerName; - - private Map<String, String> mdc; - - private String threadName; - - private Exception exception; - - public LogEntry(ServerId serverId, String message, String timestamp, String level, String loggerName, Map<String, - String> mdc, String threadName, Exception exception) { - this.serverId = serverId; - this.message = message; - this.timestamp = timestamp; - this.level = level; - this.loggerName = loggerName; - this.mdc = mdc; - this.threadName = threadName; - this.exception = exception; - } - - public LogEntry(ServerId serverId, String message, String timestamp, String level, String loggerName, Map<String, - String> mdc, String threadName) { - this.serverId = serverId; - this.message = message; - this.timestamp = timestamp; - this.level = level; - this.loggerName = loggerName; - this.mdc = mdc; - this.threadName = threadName; - } - - - public ServerId getServerId() { - return serverId; - } - - public void setServerId(ServerId serverId) { - this.serverId = serverId; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getTimestamp() { - return timestamp; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - public String getLevel() { - return level; - } - - public void setLevel(String level) { - this.level = level; - } - - public String getLoggerName() { - return loggerName; - } - - public void setLoggerName(String loggerName) { - this.loggerName = loggerName; - } - - public Map<String, String> getMdc() { - return mdc; - } - - public void setMdc(Map<String, String> mdc) { - this.mdc = mdc; - } - - public String getThreadName() { - return threadName; - } - - public void setThreadName(String threadName) { - this.threadName = threadName; - } - - public Exception getException() { - return exception; - } - - public void setException(Exception exception) { - this.exception = exception; - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCConstants.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCConstants.java b/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCConstants.java deleted file mode 100644 index 487bce0..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.common.logging; - - -public class MDCConstants { - public static final String EXPERIMENT_ID = "experiment_id"; - public static final String GATEWAY_ID = "gateway_id"; - public static final String EXPERIMENT_NAME = "experiment_name"; - public static final String PROCESS_ID = "process_id"; - public static final String TOKEN_ID = "token_id"; -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCUtil.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCUtil.java b/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCUtil.java deleted file mode 100644 index 4549d25..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/logging/MDCUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -/// -// Copyright (c) 2016. Highfive Technologies, Inc. -/// -package org.apache.airavata.common.logging; -import org.slf4j.MDC; - -import java.util.Map; - -public class MDCUtil { - public static Runnable wrapWithMDC(Runnable r) { - Map<String, String> mdc = MDC.getCopyOfContextMap(); - return () -> { - Map<String, String> oldMdc = MDC.getCopyOfContextMap(); - - if (mdc == null) { - MDC.clear(); - } else { - MDC.setContextMap(mdc); - } - try { - r.run(); - } finally { - if (oldMdc == null) { - MDC.clear(); - } else { - MDC.setContextMap(oldMdc); - } - } - - }; - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/logging/ServerId.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logging/ServerId.java b/modules/commons/src/main/java/org/apache/airavata/common/logging/ServerId.java deleted file mode 100644 index 9611302..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/logging/ServerId.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.common.logging; - -public class ServerId { - private String serverId; - private String hostName; - private String version; - - private String[] roles; // gfac, orchestrator, apiserver, - - public ServerId(String serverId, String hostName, String version, String[] roles) { - this.serverId = serverId; - this.hostName = hostName; - this.version = version; - this.roles = roles; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String[] getRoles() { - return roles; - } - - public void setRoles(String[] roles) { - this.roles = roles; - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/logging/kafka/KafkaAppender.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/logging/kafka/KafkaAppender.java b/modules/commons/src/main/java/org/apache/airavata/common/logging/kafka/KafkaAppender.java deleted file mode 100644 index e20c0e0..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/logging/kafka/KafkaAppender.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.airavata.common.logging.kafka; - - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.classic.spi.IThrowableProxy; -import ch.qos.logback.classic.spi.StackTraceElementProxy; -import ch.qos.logback.core.UnsynchronizedAppenderBase; -import com.google.gson.Gson; -import org.apache.airavata.common.logging.Exception; -import org.apache.airavata.common.logging.LogEntry; -import org.apache.airavata.common.logging.ServerId; -import org.apache.airavata.common.utils.AwsMetadata; -import org.apache.airavata.common.utils.BuildConstant; -import org.apache.airavata.common.utils.ServerSettings; -import org.apache.kafka.clients.producer.KafkaProducer; -import org.apache.kafka.clients.producer.Producer; -import org.apache.kafka.clients.producer.ProducerRecord; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.time.Instant; -import java.util.Arrays; -import java.util.Properties; - -public class KafkaAppender extends UnsynchronizedAppenderBase<ILoggingEvent> { - private final static Logger logger = LoggerFactory.getLogger(KafkaAppender.class); - - private final Producer<String, String> producer; - private final String kafkaTopic; - - private ServerId serverId = null; - - public KafkaAppender(String kafkaHost, String kafkaTopicPrefix) { - Properties props = new Properties(); - props.put("bootstrap.servers", kafkaHost); - props.put("acks", "0"); - props.put("retries", 0); - props.put("batch.size", 16384); - props.put("linger.ms", 10000); // Send the batch every 10 seconds - props.put("buffer.memory", 33554432); - props.put("producer.type", "async"); - props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); - props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); - this.kafkaTopic = createKafkaTopic(kafkaTopicPrefix); - logger.info("Starting kafka producer: bootstrap-server:{}, topic : {}", kafkaHost, this.kafkaTopic); - this.producer = new KafkaProducer<>(props); - if(ServerSettings.isRunningOnAws()) { - final AwsMetadata awsMetadata = new AwsMetadata(); - serverId = new ServerId(awsMetadata.getId(), awsMetadata.getHostname(), - BuildConstant.VERSION, ServerSettings.getServerRoles()); - } else { - serverId = new ServerId(ServerSettings.getIp(), ServerSettings.getIp(), - BuildConstant.VERSION, ServerSettings.getServerRoles()); - } - } - - @Override - protected void append(ILoggingEvent event) { - event.prepareForDeferredProcessing(); - //todo do more elegant streaming approach to publish logs - - if (!event.getLevel().equals(Level.ALL) && // OFF AND ALL are not loggable levels - !event.getLevel().equals(Level.OFF)) { - final IThrowableProxy throwableProxy = event.getThrowableProxy(); - final LogEntry entry = throwableProxy != null ? - new LogEntry(serverId, event.getFormattedMessage(), Instant.ofEpochMilli(event.getTimeStamp()).toString(), - event.getLevel().toString(), event.getLoggerName(), event.getMDCPropertyMap(), - event.getThreadName() != null ? event.getThreadName() : null, - new Exception(throwableProxy.getMessage(), toStringArray(throwableProxy.getStackTraceElementProxyArray()) - , throwableProxy.getClassName())) - : new LogEntry(serverId, event.getFormattedMessage(), Instant.ofEpochMilli(event.getTimeStamp()).toString(), - event.getLevel().toString(), event.getLoggerName(), event.getMDCPropertyMap(), - event.getThreadName() != null ? event.getThreadName() : null); - producer.send(new ProducerRecord<>(kafkaTopic, new Gson().toJson(entry))); - } - } - - - private String[] toStringArray(StackTraceElementProxy[] stackTraceElement) { - return Arrays.stream(stackTraceElement).map(StackTraceElementProxy::getSTEAsString).toArray(String[]::new); - } - - private String createKafkaTopic(String kafkaTopicPrefix) { - final String[] serverRoles = ServerSettings.getServerRoles(); - if (serverRoles.length >= 4) { - return String.format("%s_all_logs", kafkaTopicPrefix); - } - return String.format("%s_%s_logs", kafkaTopicPrefix, ServerSettings.getServerRoles()[0]); - } - - public void close() { - producer.close(); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java deleted file mode 100644 index 83e4218..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataJobState.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.common.utils; - -/* -These are the job statuses shared in database level between orchestrator and -gfac instances - */ -public class AiravataJobState { - - private State jobState; - - public State getJobState() { - return jobState; - } - - public void setJobState(State jobState) { - this.jobState = jobState; - } - - - public enum State { - CREATED { - public String toString() { - return "CREATED"; - } - }, - ACCEPTED { - public String toString() { - return "ACCEPTED"; - } - }, - FETCHED { - public String toString() { - return "FETCHED"; - } - }, - INHANDLERSDONE { - public String toString() { - return "INHANDLERSDONE"; - } - }, - SUBMITTED { - public String toString() { - return "SUBMITTED"; - } - }, - OUTHANDLERSDONE { - public String toString() { - return "OUTHANDLERSDONE"; - } - }, - RUNNING { - public String toString() { - return "RUNNING"; - } - }, - FAILED { - public String toString() { - return "FAILED"; - } - }, - PAUSED { - public String toString() { - return "PAUSED"; - } - }, - PENDING { - public String toString() { - return "PENDING"; - } - }, - ACTIVE { - public String toString() { - return "ACTIVE"; - } - }, - DONE { - public String toString() { - return "DONE"; - } - }, - CANCELLED { - public String toString() { - return "CANCELLED"; - } - }, - UNKNOWN { - public String toString() { - return "UNKNOWN"; - } - }, - HANGED { - public String toString() { - return "HANGED"; - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java deleted file mode 100644 index 37b6f0d..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataUtils.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.common.utils; - -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.UUID; - -public class AiravataUtils { - - public static Timestamp getCurrentTimestamp() { - Calendar calender = Calendar.getInstance(); -// java.util.Date d = calender.getTimeInMillis(); - return new Timestamp(calender.getTimeInMillis()); - } - - public static Timestamp getTime(long time) { - if (time == 0 || time < 0){ - return getCurrentTimestamp(); - } - return new Timestamp(time); - } - - public static String getId (String name){ - String id = name.trim().replaceAll("\\s|\\.", "_"); - return id + "_" + UUID.randomUUID(); - } -} http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/488b772f/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java ---------------------------------------------------------------------- diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java deleted file mode 100644 index 75f91fd..0000000 --- a/modules/commons/src/main/java/org/apache/airavata/common/utils/AiravataZKUtils.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.common.utils; - -import org.apache.airavata.common.exception.ApplicationSettingsException; -import org.apache.curator.framework.CuratorFramework; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher; -import org.apache.zookeeper.data.Stat; -import org.apache.zookeeper.server.ServerCnxnFactory; -import org.apache.zookeeper.server.ServerConfig; -import org.apache.zookeeper.server.ZooKeeperServer; -import org.apache.zookeeper.server.persistence.FileTxnSnapLog; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.nio.ByteBuffer; - -public class AiravataZKUtils implements Watcher { - private final static Logger logger = LoggerFactory.getLogger(AiravataZKUtils.class); - - public static final String ZK_EXPERIMENT_STATE_NODE = "state"; - public static final String DELIVERY_TAG_POSTFIX = "-deliveryTag"; - public static final String CANCEL_DELIVERY_TAG_POSTFIX = "-cancel-deliveryTag"; - - @Override - public void process(WatchedEvent event) { - - } - - public static String getExpZnodePath(String experimentId) throws ApplicationSettingsException { - return "/experiments" + File.separator + ServerSettings.getGFacServerName() + File.separator + experimentId; - } - - public static String getExpZnodeHandlerPath(String experimentId, String className) throws ApplicationSettingsException { - return "/experiments" + File.separator + ServerSettings.getGFacServerName() + File.separator + experimentId + - File.separator + className; - } - - public static String getZKhostPort() throws ApplicationSettingsException { - return ServerSettings.getZookeeperConnection(); - } - - public static int getZKTimeout()throws ApplicationSettingsException { - return ServerSettings.getZookeeperTimeout(); - } - - public static String getExpStatePath(String experimentId) throws ApplicationSettingsException { - return AiravataZKUtils.getExpZnodePath(experimentId) + - File.separator + - "state"; - } - - public static String getExpState(CuratorFramework curatorClient, String expId) throws Exception { - Stat exists = curatorClient.checkExists().forPath(getExpStatePath(expId)); - if (exists != null) { - return new String(curatorClient.getData().storingStatIn(exists).forPath(getExpStatePath(expId))); - } - return null; - } - - public static void runZKFromConfig(ServerConfig config,ServerCnxnFactory cnxnFactory) throws IOException { - AiravataZKUtils.logger.info("Starting Zookeeper server..."); - FileTxnSnapLog txnLog = null; - try { - // Note that this thread isn't going to be doing anything else, - // so rather than spawning another thread, we will just call - // run() in this thread. - // create a file logger url from the command line args - ZooKeeperServer zkServer = new ZooKeeperServer(); - - txnLog = new FileTxnSnapLog(new File(config.getDataDir()), new File( - config.getDataDir())); - zkServer.setTxnLogFactory(txnLog); - zkServer.setTickTime(config.getTickTime()); - zkServer.setMinSessionTimeout(config.getMinSessionTimeout()); - zkServer.setMaxSessionTimeout(config.getMaxSessionTimeout()); - cnxnFactory = ServerCnxnFactory.createFactory(); - cnxnFactory.configure(config.getClientPortAddress(), - config.getMaxClientCnxns()); - cnxnFactory.startup(zkServer); - cnxnFactory.join(); - if (zkServer.isRunning()) { - zkServer.shutdown(); - } - } catch (InterruptedException e) { - // warn, but generally this is ok - AiravataZKUtils.logger.warn("Server interrupted", e); - System.exit(1); - } finally { - if (txnLog != null) { - txnLog.close(); - } - } - } - - public static void startEmbeddedZK(ServerCnxnFactory cnxnFactory) { - if (ServerSettings.isEmbeddedZK()) { - ServerConfig serverConfig = new ServerConfig(); - URL resource = ApplicationSettings.loadFile("zoo.cfg"); - try { - if (resource == null) { - logger.error("There is no zoo.cfg file in the classpath... Failed to start Zookeeper Server"); - System.exit(1); - } - serverConfig.parse(resource.getPath()); - - } catch (QuorumPeerConfig.ConfigException e) { - logger.error("Error while starting embedded Zookeeper", e); - System.exit(2); - } - - final ServerConfig fServerConfig = serverConfig; - final ServerCnxnFactory fserverCnxnFactory = cnxnFactory; - (new Thread() { - public void run() { - try { - AiravataZKUtils.runZKFromConfig(fServerConfig,fserverCnxnFactory); - } catch (IOException e) { - logger.error("Error while starting embedded Zookeeper", e); - System.exit(3); - } - } - }).start(); - }else{ - logger.info("Skipping Zookeeper embedded startup ..."); - } - } - - public static byte[] toByteArray(double value) { - byte[] bytes = new byte[8]; - ByteBuffer.wrap(bytes).putDouble(value); - return bytes; - } - - public static long getDeliveryTag(String experimentID, CuratorFramework curatorClient, String experimentNode, - String pickedChild) throws Exception { - String deliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentID - + DELIVERY_TAG_POSTFIX; - Stat exists = curatorClient.checkExists().forPath(deliveryTagPath); - if(exists==null) { - logger.error("Cannot find delivery Tag in path:" + deliveryTagPath + " for this experiment"); - return -1; - } - return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(deliveryTagPath)); - } - public static byte[] longToBytes(long x) { - ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); - buffer.putLong(x); - return buffer.array(); - } - - public static long bytesToLong(byte[] bytes) { - ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES); - buffer.put(bytes); - buffer.flip();//need flip - return buffer.getLong(); - } - - public static double toDouble(byte[] bytes) { - return ByteBuffer.wrap(bytes).getDouble(); - } - - public static long getCancelDeliveryTagIfExist(String experimentId, CuratorFramework curatorClient, - String experimentNode, String pickedChild) throws Exception { - - String cancelDeliveryTagPath = experimentNode + File.separator + pickedChild + File.separator + experimentId + - AiravataZKUtils.CANCEL_DELIVERY_TAG_POSTFIX; - Stat exists = curatorClient.checkExists().forPath(cancelDeliveryTagPath); - if (exists == null) { - return -1; // no cancel deliverytag found - } else { - return bytesToLong(curatorClient.getData().storingStatIn(exists).forPath(cancelDeliveryTagPath)); - } - } -}
