http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/pom.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/pom.xml b/asterixdb/asterix-events/pom.xml deleted file mode 100644 index 9704637..0000000 --- a/asterixdb/asterix-events/pom.xml +++ /dev/null @@ -1,171 +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. - !--> - -<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"> - <modelVersion>4.0.0</modelVersion> - <parent> - <artifactId>apache-asterixdb</artifactId> - <groupId>org.apache.asterix</groupId> - <version>0.9.3-SNAPSHOT</version> - </parent> - <groupId>org.apache.asterix</groupId> - <artifactId>asterix-events</artifactId> - - <licenses> - <license> - <name>Apache License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> - <distribution>repo</distribution> - <comments>A business-friendly OSS license</comments> - </license> - </licenses> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <appendedResourcesDirectory>${basedir}/../src/main/appended-resources</appendedResourcesDirectory> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.jvnet.jaxb2.maven2</groupId> - <artifactId>maven-jaxb2-plugin</artifactId> - <executions> - <execution> - <id>event</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <args> - <arg>-Xsetters</arg> - <arg>-Xvalue-constructor</arg> - </args> - <plugins> - <plugin> - <groupId>org.jvnet.jaxb2_commons</groupId> - <artifactId>jaxb2-basics</artifactId> - <version>0.6.2</version> - </plugin> - <plugin> - <groupId>org.jvnet.jaxb2_commons</groupId> - <artifactId>jaxb2-value-constructor</artifactId> - <version>3.0</version> - </plugin> - </plugins> - <schemaDirectory>src/main/resources/schema</schemaDirectory> - <schemaIncludes> - <include>event.xsd</include> - </schemaIncludes> - <generatePackage>org.apache.asterix.event.schema.event</generatePackage> - <generateDirectory>${project.build.directory}/generated-sources/event</generateDirectory> - </configuration> - </execution> - <execution> - <id>configuration</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <args> - <arg>-Xsetters</arg> - <arg>-Xvalue-constructor</arg> - </args> - <plugins> - <plugin> - <groupId>org.jvnet.jaxb2_commons</groupId> - <artifactId>jaxb2-basics</artifactId> - <version>0.6.2</version> - </plugin> - <plugin> - <groupId>org.jvnet.jaxb2_commons</groupId> - <artifactId>jaxb2-value-constructor</artifactId> - <version>3.0</version> - </plugin> - </plugins> - <schemaDirectory>src/main/resources/schema</schemaDirectory> - <schemaIncludes> - <include>installer-conf.xsd</include> - </schemaIncludes> - <generatePackage>org.apache.asterix.installer.schema.conf</generatePackage> - <generateDirectory>${project.build.directory}/generated-sources/configuration</generateDirectory> - </configuration> - </execution> - <execution> - <id>pattern</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <args> - <arg>-Xsetters</arg> - <arg>-Xvalue-constructor</arg> - </args> - <plugins> - <plugin> - <groupId>org.jvnet.jaxb2_commons</groupId> - <artifactId>jaxb2-basics</artifactId> - <version>0.6.2</version> - </plugin> - <plugin> - <groupId>org.jvnet.jaxb2_commons</groupId> - <artifactId>jaxb2-value-constructor</artifactId> - <version>3.0</version> - </plugin> - </plugins> - <schemaDirectory>src/main/resources/schema</schemaDirectory> - <schemaIncludes> - <include>pattern.xsd</include> - </schemaIncludes> - <generatePackage>org.apache.asterix.event.schema.pattern</generatePackage> - <generateDirectory>${project.build.directory}/generated-sources/pattern</generateDirectory> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>args4j</groupId> - <artifactId>args4j</artifactId> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - <dependency> - <groupId>org.apache.zookeeper</groupId> - <artifactId>zookeeper</artifactId> - </dependency> - <dependency> - <groupId>org.apache.asterix</groupId> - <artifactId>asterix-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - </dependencies> -</project>
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventConfig.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventConfig.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventConfig.java deleted file mode 100644 index 33cb63b..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventConfig.java +++ /dev/null @@ -1,40 +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.asterix.event.driver; - -import org.kohsuke.args4j.Option; - -public class EventConfig { - - @Option(name = "-h", required = false, usage = "Help") - public boolean help = false; - - @Option(name = "-d", required = false, usage = "Show the execution on a timeline") - public boolean dryRun = false; - - @Option(name = "-s", required = false, usage = "Seed for randomization") - public int seed = -1; - - @Option(name = "-c", required = true, usage = "Path to cluster configuration (REQUIRED)") - public String clusterPath; - - @Option(name = "-p", required = true, usage = "Path to pattern configuration (REQUIRED)") - public String patternPath; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventDriver.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventDriver.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventDriver.java deleted file mode 100644 index c7f16fc..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/driver/EventDriver.java +++ /dev/null @@ -1,120 +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.asterix.event.driver; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.apache.asterix.event.management.EventUtil; -import org.apache.asterix.event.management.Randomizer; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.cluster.Property; -import org.apache.asterix.event.schema.event.Events; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.kohsuke.args4j.CmdLineParser; - -public class EventDriver { - - public static final String CLIENT_NODE_ID = "client_node"; - public static final String CLUSTER_IP = "127.0.0.1"; - public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, CLUSTER_IP, null, null, null, null, null, null, - null); - - private static String eventsDir; - private static Map<String, String> env = new HashMap<String, String>(); - private static String scriptDirSuffix; - - public static Map<String, String> getEnvironment() { - return env; - } - - public static Cluster initializeCluster(String path) throws JAXBException, IOException { - Cluster cluster = EventUtil.getCluster(path); - for (Property p : cluster.getEnv().getProperty()) { - env.put(p.getKey(), p.getValue()); - } - return cluster; - } - - public static void main(String[] args) throws Exception { - String eventsHome = System.getenv("EVENT_HOME"); - if (eventsHome == null) { - throw new IllegalStateException("EVENT_HOME is not set"); - } - eventsDir = eventsHome + File.separator + EventUtil.EVENTS_DIR; - EventConfig eventConfig = new EventConfig(); - CmdLineParser parser = new CmdLineParser(eventConfig); - try { - parser.parseArgument(args); - if (eventConfig.help) { - parser.printUsage(System.out); - } - if (eventConfig.seed > 0) { - Randomizer.getInstance(eventConfig.seed); - } - Cluster cluster = initializeCluster(eventConfig.clusterPath); - - if (!eventConfig.dryRun) { - prepare(cluster); - } - if (!eventConfig.dryRun) { - cleanup(cluster); - } - } catch (Exception e) { - e.printStackTrace(); - parser.printUsage(System.err); - } - } - - private static void prepare(Cluster cluster) throws IOException, InterruptedException { - - scriptDirSuffix = Long.toString(System.nanoTime()); - List<String> args = new ArrayList<String>(); - args.add(scriptDirSuffix); - Node clientNode = new Node(); - clientNode.setId("client"); - clientNode.setClusterIp(CLUSTER_IP); - for (Node node : cluster.getNode()) { - args.add(node.getClusterIp()); - } - EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "prepare.sh", args); - } - - private static void cleanup(Cluster cluster) throws IOException, InterruptedException { - List<String> args = new ArrayList<String>(); - args.add(scriptDirSuffix); - Node clientNode = new Node(); - clientNode.setId("client"); - clientNode.setClusterIp(CLUSTER_IP); - for (Node node : cluster.getNode()) { - args.add(node.getClusterIp()); - } - EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "cleanup.sh", args); - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/EventException.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/EventException.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/EventException.java deleted file mode 100644 index 1c63f80..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/EventException.java +++ /dev/null @@ -1,29 +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.asterix.event.error; - -public class EventException extends Exception { - - private static final long serialVersionUID = 1L; - - public EventException(String message) { - super(message); - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/OutputHandler.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/OutputHandler.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/OutputHandler.java deleted file mode 100644 index efb2ac4..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/OutputHandler.java +++ /dev/null @@ -1,87 +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.asterix.event.error; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.Properties; - -import org.apache.asterix.event.management.IOutputHandler; -import org.apache.asterix.event.management.OutputAnalysis; -import org.apache.asterix.event.model.EventList.EventType; -import org.apache.asterix.event.schema.pattern.Event; - -public class OutputHandler implements IOutputHandler { - - public static IOutputHandler INSTANCE = new OutputHandler(); - - private OutputHandler() { - - } - - @Override - public OutputAnalysis reportEventOutput(Event event, String output) { - - EventType eventType = EventType.valueOf(event.getType().toUpperCase()); - boolean ignore = true; - String trimmedOutput = output.trim(); - StringBuilder errorMessage = new StringBuilder(); - switch (eventType) { - case FILE_TRANSFER: - if (trimmedOutput.length() > 0) { - if (output.contains("Permission denied") || output.contains("cannot find or open")) { - ignore = false; - break; - } - } - break; - - case BACKUP: - case RESTORE: - if (trimmedOutput.length() > 0) { - if (trimmedOutput.contains("AccessControlException")) { - errorMessage.append("Insufficient permissions on back up directory"); - } - ignore = output.contains("does not exist") || output.contains("File exist") - || (output.contains("No such file or directory")); - } - break; - - case NODE_INFO: - Properties p = new Properties(); - try { - p.load(new ByteArrayInputStream(trimmedOutput.getBytes())); - } catch (IOException e) { - } - String javaVersion = (String) p.get("java_version"); - if (p.get("java_version") == null) { - errorMessage.append("Java not installed on " + event.getNodeid().getValue().getAbsvalue()); - ignore = false; - } else if (!javaVersion.contains("1.7")) { - errorMessage.append("Asterix requires Java 1.7.x. Incompatible version found on " - + event.getNodeid().getValue().getAbsvalue() + "\n"); - ignore = false; - } - break; - default: - break; - } - return ignore ? new OutputAnalysis(true, null) : new OutputAnalysis(false, errorMessage.toString()); - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/VerificationUtil.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/VerificationUtil.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/VerificationUtil.java deleted file mode 100644 index 640422e..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/error/VerificationUtil.java +++ /dev/null @@ -1,128 +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.asterix.event.error; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.model.AsterixRuntimeState; -import org.apache.asterix.event.model.ProcessInfo; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; - -public class VerificationUtil { - - private static final String VERIFY_SCRIPT_PATH = AsterixEventService.getEventHome() + File.separator + "scripts" - + File.separator + "verify.sh"; - - public static AsterixRuntimeState getAsterixRuntimeState(AsterixInstance instance) throws Exception { - - Cluster cluster = instance.getCluster(); - List<String> args = new ArrayList<String>(); - args.add(instance.getName()); - args.add(instance.getCluster().getMasterNode().getClusterIp()); - for (Node node : cluster.getNode()) { - args.add(node.getClusterIp()); - args.add(instance.getName() + "_" + node.getId()); - } - Thread.sleep(2000); - String output = AsterixEventServiceUtil.executeLocalScript(VERIFY_SCRIPT_PATH, args); - boolean ccRunning = true; - List<String> failedNCs = new ArrayList<String>(); - String[] infoFields; - List<ProcessInfo> processes = new ArrayList<ProcessInfo>(); - - for (String line : output.split("\n")) { - String nodeid = null; - infoFields = line.split(":"); - try { - int pid = Integer.parseInt(infoFields[3]); - if (infoFields[0].equals("NC")) { - nodeid = infoFields[2].split("_")[1]; - } else { - nodeid = instance.getCluster().getMasterNode().getId(); - } - processes.add(new ProcessInfo(infoFields[0], infoFields[1], nodeid, pid)); - } catch (Exception e) { - if (infoFields[0].equalsIgnoreCase("CC")) { - ccRunning = false; - } else { - failedNCs.add(infoFields[1]); - } - } - } - return new AsterixRuntimeState(processes, failedNCs, ccRunning); - } - - public static void updateInstanceWithRuntimeDescription(AsterixInstance instance, AsterixRuntimeState state, - boolean expectedRunning) { - StringBuilder summary = new StringBuilder(); - if (expectedRunning) { - if (!state.isCcRunning()) { - summary.append( - "Cluster Controller not running at " + instance.getCluster().getMasterNode().getId() + "\n"); - instance.setState(State.UNUSABLE); - } - if (state.getFailedNCs() != null && !state.getFailedNCs().isEmpty()) { - summary.append("Node Controller not running at the following nodes" + "\n"); - for (String failedNC : state.getFailedNCs()) { - summary.append(failedNC + "\n"); - } - // instance.setState(State.UNUSABLE); - } - if (!(instance.getState().equals(State.UNUSABLE))) { - instance.setState(State.ACTIVE); - } - } else { - if (state.getProcesses() != null && state.getProcesses().size() > 0) { - summary.append("Following process still running " + "\n"); - for (ProcessInfo pInfo : state.getProcesses()) { - summary.append(pInfo + "\n"); - } - // instance.setState(State.UNUSABLE); - } else { - // instance.setState(State.INACTIVE); - } - } - state.setSummary(summary.toString()); - instance.setAsterixRuntimeStates(state); - } - - public static void verifyBackupRestoreConfiguration(String hdfsUrl, String hadoopVersion, String hdfsBackupDir) - throws Exception { - StringBuilder errorCheck = new StringBuilder(); - if (hdfsUrl == null || hdfsUrl.length() == 0) { - errorCheck.append("\n HDFS Url not configured"); - } - if (hadoopVersion == null || hadoopVersion.length() == 0) { - errorCheck.append("\n HDFS version not configured"); - } - if (hdfsBackupDir == null || hdfsBackupDir.length() == 0) { - errorCheck.append("\n HDFS backup directory not configured"); - } - if (errorCheck.length() > 0) { - throw new Exception("Incomplete hdfs configuration" + errorCheck); - } - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/AsterixEventServiceClient.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/AsterixEventServiceClient.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/AsterixEventServiceClient.java deleted file mode 100644 index 34c1837..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/AsterixEventServiceClient.java +++ /dev/null @@ -1,232 +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.asterix.event.management; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Logger; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; - -import org.apache.asterix.event.driver.EventDriver; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.event.Events; -import org.apache.asterix.event.schema.pattern.Event; -import org.apache.asterix.event.schema.pattern.Nodeid; -import org.apache.asterix.event.schema.pattern.Pattern; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.schema.pattern.Value; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.installer.schema.conf.Configuration; - -public class AsterixEventServiceClient { - - private static final Logger LOGGER = Logger.getLogger(AsterixEventServiceClient.class.getName()); - - private EventTask[] tasks; - private boolean dryRun = false; - private LinkedBlockingQueue<EventTaskReport> msgInbox = new LinkedBlockingQueue<EventTaskReport>(); - private AtomicInteger pendingTasks = new AtomicInteger(0); - private final Cluster cluster; - private IPatternListener listener; - private IOutputHandler outputHandler; - private Events events; - private String eventsHomeDir; - private Configuration configuration; - - public AsterixEventServiceClient(Configuration configuration, String eventsHomeDir, Cluster cluster, - boolean transferArtifacts, boolean dryRun, IOutputHandler outputHandler) throws Exception { - this.eventsHomeDir = eventsHomeDir; - this.events = initializeEvents(); - this.cluster = cluster; - this.dryRun = dryRun; - this.configuration = configuration; - this.outputHandler = outputHandler; - if (!dryRun && transferArtifacts) { - initializeCluster(getEventsDir()); - } - } - - public void submit(Patterns patterns) throws Exception { - if (patterns.getPattern().isEmpty()) { - return; - } - initTasks(patterns); - try { - waitForCompletion(); - } catch (InterruptedException ie) { - LOGGER.info("Interrupted exception :" + ie); - } catch (Exception e) { - throw e; - } - - } - - public void submit(Patterns patterns, IPatternListener listener) throws Exception { - this.listener = listener; - initTasks(patterns); - } - - private void initTasks(Patterns patterns) { - tasks = new EventTask[patterns.getPattern().size()]; - pendingTasks.set(tasks.length); - int index = 0; - for (Pattern pattern : patterns.getPattern()) { - tasks[index] = new EventTask(pattern, this); - tasks[index].start(); - index++; - } - } - - public Cluster getCluster() { - return cluster; - } - - public boolean isDryRun() { - return dryRun; - } - - public Events getEvents() { - return events; - } - - public String getEventsDir() { - return eventsHomeDir + File.separator + AsterixEventServiceUtil.EVENT_DIR; - } - - public synchronized void notifyCompletion(EventTaskReport report) { - - if (report.isSuccess()) { - if (listener != null) { - pendingTasks.decrementAndGet(); - listener.eventCompleted(report); - if (pendingTasks.get() == 0) { - listener.jobCompleted(); - } - } else { - try { - msgInbox.put(report); - } catch (InterruptedException e) { - } - } - } else { - for (EventTask t : tasks) { - if (t.getState() == EventTask.State.INITIALIZED || t.getState() == EventTask.State.IN_PROGRESS) { - t.cancel(); - } - } - if (listener != null) { - listener.jobFailed(report); - } else { - try { - msgInbox.put(report); - } catch (InterruptedException e) { - } - } - } - } - - private void waitForCompletion() throws Exception { - while (true) { - EventTaskReport report = msgInbox.take(); - if (report.isSuccess()) { - if (pendingTasks.decrementAndGet() == 0) { - break; - } - } else { - throw report.getException(); - } - } - } - - private void initializeCluster(String eventsDir) throws Exception { - Patterns patterns = initPattern(eventsDir); - submit(patterns); - } - - private Patterns initPattern(String eventsDir) throws Exception { - Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId())); - List<Pattern> patternList = new ArrayList<Pattern>(); - String workingDir = cluster.getWorkingDir().getDir(); - String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername(); - patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid, - cluster.getMasterNode().getClusterIp(), workingDir)); - - JAXBContext ctx = JAXBContext.newInstance(Configuration.class); - Marshaller marshaller = ctx.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - String outputPathDir = System.getProperty("java.io.tmpdir") + File.separator + "conf-" - + System.getProperty("user.name"); - new File(outputPathDir).mkdirs(); - String outputPath = outputPathDir + File.separator + "configuration.xml"; - marshaller.marshal(configuration, new FileOutputStream(outputPath)); - - patternList.add(getFileTransferPattern(username, outputPath, nodeid, cluster.getMasterNode().getClusterIp(), - workingDir)); - - if (!cluster.getWorkingDir().isNFS()) { - for (Node node : cluster.getNode()) { - patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid, node.getClusterIp(), - workingDir)); - - } - } - return new Patterns(patternList); - } - - private Pattern getDirectoryTransferPattern(String username, String src, Nodeid srcNode, String destNodeIp, - String destDir) { - String pargs = username + " " + src + " " + destNodeIp + " " + destDir; - Event event = new Event("directory_transfer", srcNode, pargs); - return new Pattern(null, 1, null, event); - } - - private Pattern getFileTransferPattern(String username, String src, Nodeid srcNode, String destNodeIp, - String destDir) { - String pargs = username + " " + src + " " + destNodeIp + " " + destDir; - Event event = new Event("file_transfer", srcNode, pargs); - return new Pattern(null, 1, null, event); - } - - public IOutputHandler getErrorHandler() { - return outputHandler; - } - - private Events initializeEvents() throws JAXBException, FileNotFoundException { - File file = new File(getEventsDir() + File.separator + "events.xml"); - JAXBContext eventCtx = JAXBContext.newInstance(Events.class); - Unmarshaller unmarshaller = eventCtx.createUnmarshaller(); - events = (Events) unmarshaller.unmarshal(file); - return events; - } - - public String getEventsHomeDir() { - return eventsHomeDir; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventExecutor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventExecutor.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventExecutor.java deleted file mode 100644 index 5035072..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventExecutor.java +++ /dev/null @@ -1,120 +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.asterix.event.management; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import org.apache.asterix.event.driver.EventDriver; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.cluster.Property; -import org.apache.asterix.event.schema.pattern.Pattern; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.commons.io.IOUtils; - -public class EventExecutor { - - private static final String EXECUTE_SCRIPT = "execute.sh"; - private static final String IP_LOCATION = "IP_LOCATION"; - private static final String CLUSTER_ENV = "ENV"; - private static final String SCRIPT = "SCRIPT"; - private static final String ARGS = "ARGS"; - private static final String DAEMON = "DAEMON"; - - public void executeEvent(Node node, String script, List<String> args, boolean isDaemon, Cluster cluster, - Pattern pattern, IOutputHandler outputHandler, AsterixEventServiceClient client) throws IOException { - List<String> pargs = new ArrayList<>(); - pargs.add("/bin/bash"); - pargs.add(client.getEventsHomeDir() + File.separator + AsterixEventServiceUtil.EVENT_DIR + File.separator - + EXECUTE_SCRIPT); - StringBuilder envBuffer = new StringBuilder(IP_LOCATION + "=" + node.getClusterIp() + " "); - boolean isMasterNode = node.getId().equals(cluster.getMasterNode().getId()); - - if (!node.getId().equals(EventDriver.CLIENT_NODE_ID) && cluster.getEnv() != null) { - for (Property p : cluster.getEnv().getProperty()) { - if (p.getKey().equals("JAVA_HOME")) { - String val = node.getJavaHome() == null ? p.getValue() : node.getJavaHome(); - envBuffer.append(p.getKey() + "=" + val + " "); - } else if (p.getKey().equals(EventUtil.NC_JAVA_OPTS)) { - if (!isMasterNode) { - appendJavaOpts(node, envBuffer, p); - } - } else if (p.getKey().equals(EventUtil.CC_JAVA_OPTS)) { - if (isMasterNode) { - appendJavaOpts(node, envBuffer, p); - } - } else if (p.getKey().equals("LOG_DIR")) { - String val = node.getLogDir() == null ? p.getValue() : node.getLogDir(); - envBuffer.append(p.getKey() + "=" + val + " "); - } else { - envBuffer.append(p.getKey() + "=" + p.getValue() + " "); - } - - } - pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername()); - } - - StringBuilder argBuffer = new StringBuilder(); - if (args != null && args.size() > 0) { - for (String arg : args) { - argBuffer.append(arg + " "); - } - } - - ProcessBuilder pb = new ProcessBuilder(pargs); - pb.environment().put(IP_LOCATION, node.getClusterIp()); - pb.environment().put(CLUSTER_ENV, envBuffer.toString()); - pb.environment().put(SCRIPT, script); - pb.environment().put(ARGS, argBuffer.toString()); - pb.environment().put(DAEMON, Boolean.toString(isDaemon)); - Process p = pb.start(); - if (!isDaemon) { - BufferedInputStream bis = new BufferedInputStream(p.getInputStream()); - StringWriter writer = new StringWriter(); - IOUtils.copy(bis, writer, "UTF-8"); - String result = writer.getBuffer().toString(); - OutputAnalysis analysis = outputHandler.reportEventOutput(pattern.getEvent(), result); - if (!analysis.isExpected()) { - throw new IOException(analysis.getErrorMessage() + result); - } - } - } - - protected void appendJavaOpts(Node node, StringBuilder envBuffer, Property p) { - StringBuilder builder = new StringBuilder(); - builder.append("\""); - String javaOpts = p.getValue(); - if (javaOpts != null) { - builder.append(javaOpts); - } - if (node.getDebugPort() != null) { - int debugPort = node.getDebugPort().intValue(); - if (javaOpts == null || !javaOpts.contains("-Xdebug")) { - builder.append(" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=").append(debugPort); - } - } - builder.append("\""); - envBuffer.append("JAVA_OPTS=").append(builder.toString()).append(" "); - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTask.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTask.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTask.java deleted file mode 100644 index afd53de..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTask.java +++ /dev/null @@ -1,154 +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.asterix.event.management; - -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -import org.apache.log4j.Logger; - -import org.apache.asterix.event.driver.EventDriver; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.event.Event; -import org.apache.asterix.event.schema.pattern.Pattern; -import org.apache.asterix.event.schema.pattern.Period; - -public class EventTask extends TimerTask { - - public static enum State { - INITIALIZED, - IN_PROGRESS, - COMPLETED, - FAILED - } - - private static final Logger logger = Logger.getLogger(EventTask.class.getName()); - - private Pattern pattern; - private Event event; - private long interval = 0; - private long initialDelay = 0; - private int maxOccurs = Integer.MAX_VALUE; - private int occurrenceCount = 0; - private Timer timer; - private String taskScript; - private Node location; - private List<String> taskArgs; - private AsterixEventServiceClient client; - private List<Node> candidateLocations; - private boolean dynamicLocation = false; - private boolean reuseLocation = false; - private State state; - - public EventTask(Pattern pattern, AsterixEventServiceClient client) { - this.pattern = pattern; - this.client = client; - Period period = pattern.getPeriod(); - if (period != null && period.getAbsvalue() != null) { - this.interval = EventUtil.parseTimeInterval(period.getAbsvalue(), period.getUnit()); - } - if (pattern.getDelay() != null) { - this.initialDelay = EventUtil.parseTimeInterval(new ValueType(pattern.getDelay().getValue()), pattern - .getDelay().getUnit()); - } - if (pattern.getMaxOccurs() != null) { - this.maxOccurs = pattern.getMaxOccurs(); - } - this.timer = new Timer(); - taskArgs = EventUtil.getEventArgs(pattern); - candidateLocations = EventUtil.getCandidateLocations(pattern, client.getCluster()); - if (pattern.getEvent().getNodeid().getValue().getRandom() != null && period != null && maxOccurs > 1) { - dynamicLocation = true; - reuseLocation = pattern.getEvent().getNodeid().getValue().getRandom().getRange().isReuse(); - } else { - location = EventUtil.getEventLocation(pattern, candidateLocations, client.getCluster()); - } - String scriptsDir; - if (location.getId().equals(EventDriver.CLIENT_NODE_ID)) { - scriptsDir = client.getEventsDir(); - } else { - scriptsDir = client.getCluster().getWorkingDir().getDir() + File.separator + "events"; - } - event = EventUtil.getEvent(pattern, client.getEvents()); - taskScript = scriptsDir + File.separator + event.getScript(); - state = State.INITIALIZED; - } - - public void start() { - if (interval > 0) { - timer.schedule(this, initialDelay, interval); - } else { - timer.schedule(this, initialDelay); - } - } - - @Override - public void run() { - if (candidateLocations.size() == 0) { - timer.cancel(); - client.notifyCompletion(new EventTaskReport(this)); - } else { - if (dynamicLocation) { - location = EventUtil.getEventLocation(pattern, candidateLocations, client.getCluster()); - if (!reuseLocation) { - candidateLocations.remove(location); - } - } - - logger.debug(EventUtil.dateFormat.get().format(new Date()) + " " + "EVENT " - + pattern.getEvent().getType().toUpperCase() + " at " + location.getId().toUpperCase()); - try { - if (!client.isDryRun()) { - new EventExecutor().executeEvent(location, taskScript, taskArgs, event.isDaemon(), - client.getCluster(), pattern, client.getErrorHandler(), client); - } - occurrenceCount++; - if (occurrenceCount >= maxOccurs) { - timer.cancel(); - client.notifyCompletion(new EventTaskReport(this)); - } - } catch (IOException ioe) { - timer.cancel(); - client.notifyCompletion(new EventTaskReport(this, false, ioe)); - } - } - - } - - public Node getLocation() { - return location; - } - - public long getInterval() { - return interval; - } - - public Pattern getPattern() { - return pattern; - } - - public State getState() { - return state; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTaskReport.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTaskReport.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTaskReport.java deleted file mode 100644 index 82f303a..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventTaskReport.java +++ /dev/null @@ -1,54 +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.asterix.event.management; - -import java.io.Serializable; - -public class EventTaskReport implements Serializable { - - private static final long serialVersionUID = 1L; - private final EventTask task; - private final boolean success; - private final Exception e; - - public EventTaskReport(EventTask task, boolean success, Exception e) { - this.task = task; - this.success = success; - this.e = e; - } - - public EventTaskReport(EventTask task) { - this.task = task; - this.success = true; - this.e = null; - } - - public Exception getException() { - return e; - } - - public EventTask getTask() { - return task; - } - - public boolean isSuccess() { - return success; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventUtil.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventUtil.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventUtil.java deleted file mode 100644 index 9d684ec..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/EventUtil.java +++ /dev/null @@ -1,234 +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.asterix.event.management; - -import java.io.File; -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.apache.asterix.event.driver.EventDriver; -import org.apache.asterix.event.management.ValueType.Type; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.event.Event; -import org.apache.asterix.event.schema.event.Events; -import org.apache.asterix.event.schema.pattern.Pattern; - -public class EventUtil { - - public static final String EVENTS_DIR = "events"; - public static final ThreadLocal<DateFormat> dateFormat = - ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")); - public static final String NC_JAVA_OPTS = "nc.java.opts"; - public static final String CC_JAVA_OPTS = "cc.java.opts"; - - private static final String IP_LOCATION = "IP_LOCATION"; - - public static Cluster getCluster(String clusterConfigurationPath) throws JAXBException { - File file = new File(clusterConfigurationPath); - JAXBContext ctx = JAXBContext.newInstance(Cluster.class); - Unmarshaller unmarshaller = ctx.createUnmarshaller(); - Cluster cluster = (Cluster) unmarshaller.unmarshal(file); - return cluster; - } - - public static long parseTimeInterval(ValueType v, String unit) throws IllegalArgumentException { - int val = 0; - switch (v.getType()) { - case ABS: - val = Integer.parseInt(v.getAbsoluteValue()); - break; - case RANDOM_MIN_MAX: - val = Randomizer.getInstance().getRandomInt(v.getMin(), v.getMax()); - break; - case RANDOM_RANGE: - String[] values = v.getRangeSet(); - val = Integer.parseInt(values[Randomizer.getInstance().getRandomInt(0, values.length - 1)]); - break; - } - return computeInterval(val, unit); - } - - public static long parseTimeInterval(String v, String unit) throws IllegalArgumentException { - int value = Integer.parseInt(v); - return computeInterval(value, unit); - } - - private static long computeInterval(int val, String unit) { - int vmult = 1; - if ("hr".equalsIgnoreCase(unit)) { - vmult = 3600 * 1000; - } else if ("min".equalsIgnoreCase(unit)) { - vmult = 60 * 1000; - } else if ("sec".equalsIgnoreCase(unit)) { - vmult = 1000; - } else - throw new IllegalArgumentException(" invalid unit value specified for frequency (hr,min,sec)"); - return val * vmult; - - } - - public static Event getEvent(Pattern pattern, Events events) { - for (Event event : events.getEvent()) { - if (event.getType().equals(pattern.getEvent().getType())) { - return event; - } - } - throw new IllegalArgumentException(" Unknown event type" + pattern.getEvent().getType()); - } - - public static Node getEventLocation(Pattern pattern, List<Node> candidateLocations, Cluster cluster) { - ValueType value = new ValueType(pattern.getEvent().getNodeid().getValue()); - Node location = null; - Type vtype = value.getType(); - - switch (vtype) { - case ABS: - location = getNodeFromId(value.getAbsoluteValue(), cluster); - break; - case RANDOM_RANGE: - int nodeIndex = Randomizer.getInstance().getRandomInt(0, candidateLocations.size() - 1); - location = candidateLocations.get(nodeIndex); - break; - case RANDOM_MIN_MAX: - throw new IllegalStateException(" Canont configure a min max value range for location"); - } - return location; - - } - - public static List<Node> getCandidateLocations(Pattern pattern, Cluster cluster) { - ValueType value = new ValueType(pattern.getEvent().getNodeid().getValue()); - List<Node> candidateList = new ArrayList<Node>(); - switch (value.getType()) { - case ABS: - candidateList.add(getNodeFromId(value.getAbsoluteValue(), cluster)); - break; - case RANDOM_RANGE: - boolean anyOption = false; - String[] values = value.getRangeSet(); - for (String v : values) { - if (v.equalsIgnoreCase("ANY")) { - anyOption = true; - } - } - if (anyOption) { - for (Node node : cluster.getNode()) { - candidateList.add(node); - } - } else { - boolean found = false; - for (String v : values) { - for (Node node : cluster.getNode()) { - if (node.getId().equals(v)) { - candidateList.add(node); - found = true; - break; - } - } - if (!found) { - throw new IllegalStateException("Unknonw nodeId : " + v); - } - found = false; - } - - } - String[] excluded = value.getRangeExcluded(); - if (excluded != null && excluded.length > 0) { - List<Node> markedForRemoval = new ArrayList<Node>(); - for (String exclusion : excluded) { - for (Node node : candidateList) { - if (node.getId().equals(exclusion)) { - markedForRemoval.add(node); - } - } - } - candidateList.removeAll(markedForRemoval); - } - break; - case RANDOM_MIN_MAX: - throw new IllegalStateException(" Invalid value configured for location"); - } - return candidateList; - } - - private static Node getNodeFromId(String nodeid, Cluster cluster) { - if (nodeid.equals(EventDriver.CLIENT_NODE.getId())) { - return EventDriver.CLIENT_NODE; - } - - if (nodeid.equals(cluster.getMasterNode().getId())) { - String logDir = cluster.getMasterNode().getLogDir() == null ? cluster.getLogDir() : cluster.getMasterNode() - .getLogDir(); - String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster.getJavaHome() : cluster - .getMasterNode().getJavaHome(); - return new Node(cluster.getMasterNode().getId(), cluster.getMasterNode().getClusterIp(), javaHome, logDir, - null, null, cluster.getMasterNode().getDebugPort(), null, null); - } - - List<Node> nodeList = cluster.getNode(); - for (Node node : nodeList) { - if (node.getId().equals(nodeid)) { - return node; - } - } - StringBuilder buffer = new StringBuilder(); - buffer.append(EventDriver.CLIENT_NODE.getId() + ","); - buffer.append(cluster.getMasterNode().getId() + ","); - for (Node v : cluster.getNode()) { - buffer.append(v.getId() + ","); - } - buffer.deleteCharAt(buffer.length() - 1); - throw new IllegalArgumentException("Unknown node id :" + nodeid + " valid ids:" + buffer); - } - - public static void executeLocalScript(Node node, String script, List<String> args) throws IOException, - InterruptedException { - List<String> pargs = new ArrayList<String>(); - pargs.add("/bin/bash"); - pargs.add(script); - if (args != null) { - pargs.addAll(args); - } - ProcessBuilder pb = new ProcessBuilder(pargs); - pb.environment().putAll(EventDriver.getEnvironment()); - pb.environment().put(IP_LOCATION, node.getClusterIp()); - pb.start(); - } - - public static List<String> getEventArgs(Pattern pattern) { - List<String> pargs = new ArrayList<String>(); - if (pattern.getEvent().getPargs() == null) { - return pargs; - } - String[] args = pattern.getEvent().getPargs().split(" "); - for (String arg : args) { - pargs.add(arg.trim()); - } - return pargs; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IOutputHandler.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IOutputHandler.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IOutputHandler.java deleted file mode 100644 index d2c3242..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IOutputHandler.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.asterix.event.management; - -import org.apache.asterix.event.schema.pattern.Event; - -public interface IOutputHandler { - - public OutputAnalysis reportEventOutput(Event event, String output); -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IPatternListener.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IPatternListener.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IPatternListener.java deleted file mode 100644 index e075140..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/IPatternListener.java +++ /dev/null @@ -1,28 +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.asterix.event.management; - -public interface IPatternListener { - - public void eventCompleted(EventTaskReport report); - - public void jobCompleted(); - - public void jobFailed(EventTaskReport report); -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/OutputAnalysis.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/OutputAnalysis.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/OutputAnalysis.java deleted file mode 100644 index 86baeb7..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/OutputAnalysis.java +++ /dev/null @@ -1,38 +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.asterix.event.management; - -public class OutputAnalysis { - - private final boolean expected; - private final String errorMessage; - - public OutputAnalysis(boolean expected, String errorMessage) { - this.expected = expected; - this.errorMessage = errorMessage; - } - - public boolean isExpected() { - return expected; - } - - public String getErrorMessage() { - return errorMessage; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/Randomizer.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/Randomizer.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/Randomizer.java deleted file mode 100644 index 347ffce..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/Randomizer.java +++ /dev/null @@ -1,69 +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.asterix.event.management; - -import java.util.Random; -import java.util.logging.Logger; - -public class Randomizer { - - private static final Logger LOGGER = Logger.getLogger(Randomizer.class.getName()); - private static Randomizer INSTANCE; - private final Random random; - private final int seed; - - public static Randomizer getInstance(int seed) { - if (INSTANCE == null) { - INSTANCE = new Randomizer(seed); - } - return INSTANCE; - } - - public static Randomizer getInstance() { - if (INSTANCE == null) { - INSTANCE = new Randomizer(); - } - return INSTANCE; - } - - private Randomizer() { - Random rm = new Random(); - seed = rm.nextInt(10000); - random = new Random(seed); - LOGGER.info("SEED:" + seed); - } - - private Randomizer(int seed) { - this.seed = seed; - random = new Random(seed); - LOGGER.info("SEED:" + seed); - } - - public Random getRandom() { - return random; - } - - public int getSeed() { - return seed; - } - - public int getRandomInt(int min, int max) { - return min + random.nextInt(max - min + 1); - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ValueType.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ValueType.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ValueType.java deleted file mode 100644 index 2fc7eeb..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ValueType.java +++ /dev/null @@ -1,99 +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.asterix.event.management; - -import org.apache.asterix.event.schema.pattern.Value; - -public class ValueType { - - public static enum Type { - ABS, - RANDOM_RANGE, - RANDOM_MIN_MAX - } - - private Value value; - private Type type; - - public ValueType(Value value) { - this.value = value; - if (value.getAbsvalue() != null) { - type = Type.ABS; - } else if (value.getRandom() != null) { - if (value.getRandom().getMinmax() != null) { - type = Type.RANDOM_MIN_MAX; - } else if (value.getRandom().getRange() != null) { - type = Type.RANDOM_RANGE; - } else { - throw new IllegalStateException("Incorrect value type"); - } - } - } - - public int getMin() { - switch (type) { - case RANDOM_MIN_MAX: - return Integer.parseInt(value.getRandom().getMinmax().getMin()); - default: - throw new IllegalStateException(""); - } - } - - public int getMax() { - switch (type) { - case RANDOM_MIN_MAX: - return Integer.parseInt(value.getRandom().getMinmax().getMax()); - default: - throw new IllegalStateException(""); - } - } - - public String[] getRangeSet() { - switch (type) { - case RANDOM_RANGE: - return value.getRandom().getRange().getSet().split(" "); - default: - throw new IllegalStateException(""); - } - } - - public String[] getRangeExcluded() { - switch (type) { - case RANDOM_RANGE: - String exl = value.getRandom().getRange().getExclude(); - return exl != null ? exl.split(" ") : null; - default: - throw new IllegalStateException(""); - } - } - - public String getAbsoluteValue() { - switch (type) { - case ABS: - return value.getAbsvalue(); - default: - throw new IllegalStateException(""); - } - } - - public Type getType() { - return type; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixInstance.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixInstance.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixInstance.java deleted file mode 100644 index f824d5b..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixInstance.java +++ /dev/null @@ -1,202 +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.asterix.event.model; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.apache.asterix.common.configuration.AsterixConfiguration; -import org.apache.asterix.common.configuration.Property; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; - -public class AsterixInstance implements Serializable { - - private static final long serialVersionUID = 1L; - - private static final int WEB_INTERFACE_PORT_DEFAULT = 19001; - - public enum State { - ACTIVE, - INACTIVE, - UNUSABLE - } - - private final Cluster cluster; - private final String name; - private final Date createdTimestamp; - private Date stateChangeTimestamp; - private Date modifiedTimestamp; - private AsterixConfiguration asterixConfiguration; - private State state; - private final String metadataNodeId; - private final String asterixVersion; - private final List<BackupInfo> backupInfo; - private AsterixRuntimeState runtimeState; - private State previousState; - - public AsterixInstance(String name, Cluster cluster, AsterixConfiguration asterixConfiguration, - String metadataNodeId, String asterixVersion) { - this.name = name; - this.cluster = cluster; - this.asterixConfiguration = asterixConfiguration; - this.metadataNodeId = metadataNodeId; - this.state = State.ACTIVE; - this.previousState = State.UNUSABLE; - this.asterixVersion = asterixVersion; - this.createdTimestamp = new Date(); - this.backupInfo = new ArrayList<BackupInfo>(); - } - - public State getState() { - return state; - } - - public void setState(State state) { - this.previousState = this.state; - this.state = state; - } - - public Cluster getCluster() { - return cluster; - } - - public String getName() { - return name; - } - - public void setStateChangeTimestamp(Date stateChangeTimestamp) { - this.stateChangeTimestamp = stateChangeTimestamp; - } - - public void setModifiedTimestamp(Date modifiedTimestamp) { - this.modifiedTimestamp = modifiedTimestamp; - } - - public String getMetadataNodeId() { - return metadataNodeId; - } - - public String getAsterixVersion() { - return asterixVersion; - } - - public String getDescription(boolean detailed) { - StringBuilder buffer = new StringBuilder(); - buffer.append("Name:" + name + "\n"); - buffer.append("Created:" + createdTimestamp + "\n"); - - buffer.append("Web-Url:" + getWebInterfaceUrl() + "\n"); - buffer.append("State:" + state); - if (!state.equals(State.UNUSABLE) && stateChangeTimestamp != null) { - buffer.append(" (" + stateChangeTimestamp + ")" + "\n"); - } else { - buffer.append("\n"); - } - if (modifiedTimestamp != null) { - buffer.append("Last modified timestamp:" + modifiedTimestamp + "\n"); - } - - if (runtimeState.getSummary() != null && runtimeState.getSummary().length() > 0) { - buffer.append("\nWARNING!:" + runtimeState.getSummary() + "\n"); - } - if (detailed) { - addDetailedInformation(buffer); - } - return buffer.toString(); - } - - public List<BackupInfo> getBackupInfo() { - return backupInfo; - } - - public String getWebInterfaceUrl() { - int webPort = WEB_INTERFACE_PORT_DEFAULT; - for (Property p : asterixConfiguration.getProperty()) { - if (p.getName().equalsIgnoreCase("web.port")) { - webPort = Integer.parseInt(p.getValue()); - } - } - return "http://" + cluster.getMasterNode().getClientIp() + ":" + webPort; - } - - public void setAsterixRuntimeStates(AsterixRuntimeState runtimeState) { - this.runtimeState = runtimeState; - } - - private void addDetailedInformation(StringBuilder buffer) { - buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getClusterIp() - + "\n"); - for (Node node : cluster.getNode()) { - buffer.append(node.getId() + ":" + node.getClusterIp() + "\n"); - } - - if (backupInfo != null && backupInfo.size() > 0) { - for (BackupInfo info : backupInfo) { - buffer.append(info + "\n"); - } - } - buffer.append("\n"); - buffer.append("Asterix version:" + asterixVersion + "\n"); - buffer.append("Metadata Node:" + metadataNodeId + "\n"); - buffer.append("Processes" + "\n"); - for (ProcessInfo pInfo : runtimeState.getProcesses()) { - buffer.append(pInfo + "\n"); - } - - buffer.append("\n"); - buffer.append("Asterix Configuration\n"); - int lenMax = 0; - for (Property property : asterixConfiguration.getProperty()) { - int nextLen = property.getName().length(); - if (nextLen > lenMax) { - lenMax = nextLen; - } - } - for (Property property : asterixConfiguration.getProperty()) { - buffer.append(property.getName() + getIndentation(property.getName(), lenMax) + ":" + property.getValue() - + "\n"); - } - - } - - private String getIndentation(String name, int lenMax) { - int len = name.length(); - StringBuilder buf = new StringBuilder(); - for (int i = 0; i < lenMax - len; i++) { - buf.append(" "); - } - return buf.toString(); - } - - public State getPreviousState() { - return previousState; - } - - public AsterixConfiguration getAsterixConfiguration() { - return asterixConfiguration; - } - - public void setAsterixConfiguration(AsterixConfiguration asterixConfiguration) { - this.asterixConfiguration = asterixConfiguration; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixRuntimeState.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixRuntimeState.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixRuntimeState.java deleted file mode 100644 index a1c4418..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/AsterixRuntimeState.java +++ /dev/null @@ -1,58 +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.asterix.event.model; - -import java.io.Serializable; -import java.util.List; - -public class AsterixRuntimeState implements Serializable { - - private static final long serialVersionUID = 1L; - private final List<ProcessInfo> processes; - private final List<String> failedNCs; - private final boolean ccRunning; - private String summary; - - public AsterixRuntimeState(List<ProcessInfo> processes, List<String> failedNCs, boolean ccRunning) { - this.processes = processes; - this.failedNCs = failedNCs; - this.ccRunning = ccRunning; - } - - public List<ProcessInfo> getProcesses() { - return processes; - } - - public List<String> getFailedNCs() { - return failedNCs; - } - - public boolean isCcRunning() { - return ccRunning; - } - - public void setSummary(String summary) { - this.summary = summary; - } - - public String getSummary() { - return summary; - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/BackupInfo.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/BackupInfo.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/BackupInfo.java deleted file mode 100644 index ae10cd7..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/BackupInfo.java +++ /dev/null @@ -1,72 +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.asterix.event.model; - -import java.io.Serializable; -import java.util.Date; - -import org.apache.asterix.installer.schema.conf.Backup; -import org.apache.asterix.installer.schema.conf.Hdfs; - -public class BackupInfo implements Serializable { - private static final long serialVersionUID = 1L; - - public static enum BackupType { - LOCAL, - HDFS - }; - - private final int id; - private final Date date; - private final Backup backupConf; - - public BackupInfo(int id, Date date, Backup backupConf) { - this.id = id; - this.date = date; - this.backupConf = backupConf; - } - - public int getId() { - return id; - } - - public Date getDate() { - return date; - } - - public Backup getBackupConf() { - return backupConf; - } - - @Override - public String toString() { - return id + " " + date + " " + "(" + getBackupType() + ")" + " " + "[ " + this.getBackupConf().getBackupDir() - + " ]"; - } - - public BackupType getBackupType() { - return getBackupType(this.getBackupConf()); - } - - public static BackupType getBackupType(Backup backupConf) { - Hdfs hdfs = backupConf.getHdfs(); - return (hdfs != null && hdfs.getUrl() != null && hdfs.getUrl().length() > 0) ? BackupType.HDFS - : BackupType.LOCAL; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/EventList.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/EventList.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/EventList.java deleted file mode 100644 index dba84c6..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/EventList.java +++ /dev/null @@ -1,38 +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.asterix.event.model; - -public class EventList { - - public enum EventType { - NODE_JOIN, - NODE_FAILURE, - CC_START, - CC_FAILURE, - BACKUP, - RESTORE, - FILE_DELETE, - HDFS_DELETE, - FILE_TRANSFER, - FILE_CREATE, - DIRECTORY_TRANSFER, - DIRECTORY_COPY, - NODE_INFO - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/ProcessInfo.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/ProcessInfo.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/ProcessInfo.java deleted file mode 100644 index 9702ceb..0000000 --- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/model/ProcessInfo.java +++ /dev/null @@ -1,50 +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.asterix.event.model; - -import java.io.Serializable; - -public class ProcessInfo implements Serializable { - - private static final long serialVersionUID = 304186774065853730L; - private final String processName; - private final String host; - private final String nodeId; - private final int processId; - - public ProcessInfo(String processName, String host, String nodeId, int processId) { - this.processName = processName; - this.host = host; - this.nodeId = nodeId; - this.processId = processId; - } - - public String getHost() { - return host; - } - - public String getNodeId() { - return nodeId; - } - - public String toString() { - return processName + " at " + nodeId + " [ " + processId + " ] "; - } - -}
