dead code elimination in asterix-events
Change-Id: I8873652ca6b3add003e7454d09c175b2218ed685
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1300
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/api/ClusterInfo.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/api/ClusterInfo.java
deleted file mode 100644
index d996e0e..0000000
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/api/ClusterInfo.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.asterix.event.api;
-
-import java.util.List;
-
-public class ClusterInfo {
-
- List<NodeInfo> nodes;
-
- public ClusterInfo(List<NodeInfo> nodes) {
- this.nodes = nodes;
- }
-}
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/api/NodeInfo.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/api/NodeInfo.java
deleted file mode 100644
index d2dab4c..0000000
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/api/NodeInfo.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.api;
-
-public class NodeInfo {
-
- private final String id;
- private final String ip;
-
- public NodeInfo(String id, String ip) {
- this.id = id;
- this.ip = ip;
- }
-
- public String getId() {
- return id;
- }
-
- public String getIp() {
- return ip;
- }
-}
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
index c92262c..415433e 100644
--- 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
@@ -41,33 +41,17 @@
public class EventDriver {
public static final String CLIENT_NODE_ID = "client_node";
- public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null, null);
+ 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);
private static String eventsDir;
- private static Events events;
private static Map<String, String> env = new HashMap<String, String>();
private static String scriptDirSuffix;
- public static String getEventsDir() {
- return eventsDir;
- }
-
- public static Events getEvents() {
- return events;
- }
-
public static Map<String, String> getEnvironment() {
return env;
}
- public static String getStringifiedEnv(Cluster cluster) {
- StringBuffer buffer = new StringBuffer();
- for (Property p : cluster.getEnv().getProperty()) {
- buffer.append(p.getKey() + "=" + p.getValue() + " ");
- }
- return buffer.toString();
- }
-
public static Cluster initializeCluster(String path) throws JAXBException, IOException {
Cluster cluster = EventUtil.getCluster(path);
for (Property p : cluster.getEnv().getProperty()) {
@@ -76,17 +60,6 @@
return cluster;
}
- public static Patterns initializePatterns(String path) throws JAXBException, IOException {
- File file = new File(path);
- JAXBContext ctx = JAXBContext.newInstance(Patterns.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- return (Patterns) unmarshaller.unmarshal(file);
- }
-
- private static void initialize(EventConfig eventConfig) throws IOException, JAXBException {
-
- }
-
public static void main(String[] args) throws Exception {
String eventsHome = System.getenv("EVENT_HOME");
if (eventsHome == null) {
@@ -104,14 +77,10 @@
Randomizer.getInstance(eventConfig.seed);
}
Cluster cluster = initializeCluster(eventConfig.clusterPath);
- initialize(eventConfig);
if (!eventConfig.dryRun) {
prepare(cluster);
}
- //AsterixEventServiceClient client = new AsterixEventServiceClient(eventsDir, cluster, eventConfig.dryRun,
- // new DefaultOutputHandler());
- // client.submit(patterns);
if (!eventConfig.dryRun) {
cleanup(cluster);
}
@@ -123,12 +92,12 @@
private static void prepare(Cluster cluster) throws IOException, InterruptedException {
- scriptDirSuffix = "" + System.nanoTime();
+ scriptDirSuffix = Long.toString(System.nanoTime());
List<String> args = new ArrayList<String>();
args.add(scriptDirSuffix);
Node clientNode = new Node();
clientNode.setId("client");
- clientNode.setClusterIp("127.0.0.1");
+ clientNode.setClusterIp(CLUSTER_IP);
for (Node node : cluster.getNode()) {
args.add(node.getClusterIp());
}
@@ -140,7 +109,7 @@
args.add(scriptDirSuffix);
Node clientNode = new Node();
clientNode.setId("client");
- clientNode.setClusterIp("127.0.0.1");
+ clientNode.setClusterIp(CLUSTER_IP);
for (Node node : cluster.getNode()) {
args.add(node.getClusterIp());
}
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
index 68e87c6..efb2ac4 100644
--- 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
@@ -41,7 +41,7 @@
EventType eventType = EventType.valueOf(event.getType().toUpperCase());
boolean ignore = true;
String trimmedOutput = output.trim();
- StringBuffer errorMessage = new StringBuffer();
+ StringBuilder errorMessage = new StringBuilder();
switch (eventType) {
case FILE_TRANSFER:
if (trimmedOutput.length() > 0) {
@@ -57,14 +57,9 @@
if (trimmedOutput.length() > 0) {
if (trimmedOutput.contains("AccessControlException")) {
errorMessage.append("Insufficient permissions on back up directory");
- ignore = false;
}
- if (output.contains("does not exist") || output.contains("File exist")
- || (output.contains("No such file or directory"))) {
- ignore = true;
- } else {
- ignore = false;
- }
+ ignore = output.contains("does not exist") || output.contains("File exist")
+ || (output.contains("No such file or directory"));
}
break;
@@ -87,10 +82,6 @@
default:
break;
}
- if (ignore) {
- return new OutputAnalysis(true, null);
- } else {
- return new OutputAnalysis(false, errorMessage.toString());
- }
+ return ignore ? new OutputAnalysis(true, null) : new OutputAnalysis(false, errorMessage.toString());
}
}
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
index 71efa44..640422e 100644
--- 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
@@ -51,7 +51,6 @@
boolean ccRunning = true;
List<String> failedNCs = new ArrayList<String>();
String[] infoFields;
- ProcessInfo pInfo;
List<ProcessInfo> processes = new ArrayList<ProcessInfo>();
for (String line : output.split("\n")) {
@@ -64,8 +63,7 @@
} else {
nodeid = instance.getCluster().getMasterNode().getId();
}
- pInfo = new ProcessInfo(infoFields[0], infoFields[1], nodeid, pid);
- processes.add(pInfo);
+ processes.add(new ProcessInfo(infoFields[0], infoFields[1], nodeid, pid));
} catch (Exception e) {
if (infoFields[0].equalsIgnoreCase("CC")) {
ccRunning = false;
@@ -79,11 +77,11 @@
public static void updateInstanceWithRuntimeDescription(AsterixInstance instance, AsterixRuntimeState state,
boolean expectedRunning) {
- StringBuffer summary = new StringBuffer();
+ StringBuilder summary = new StringBuilder();
if (expectedRunning) {
if (!state.isCcRunning()) {
- summary.append("Cluster Controller not running at " + instance.getCluster().getMasterNode().getId()
- + "\n");
+ summary.append(
+ "Cluster Controller not running at " + instance.getCluster().getMasterNode().getId() + "\n");
instance.setState(State.UNUSABLE);
}
if (state.getFailedNCs() != null && !state.getFailedNCs().isEmpty()) {
@@ -113,7 +111,7 @@
public static void verifyBackupRestoreConfiguration(String hdfsUrl, String hadoopVersion, String hdfsBackupDir)
throws Exception {
- StringBuffer errorCheck = new StringBuffer();
+ StringBuilder errorCheck = new StringBuilder();
if (hdfsUrl == null || hdfsUrl.length() == 0) {
errorCheck.append("\n HDFS Url not configured");
}
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
index af33f2e..34c1837 100644
--- 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
@@ -196,8 +196,7 @@
}
}
- Patterns patterns = new Patterns(patternList);
- return patterns;
+ return new Patterns(patternList);
}
private Pattern getDirectoryTransferPattern(String username, String src, Nodeid srcNode, String destNodeIp,
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/DefaultOutputHandler.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/DefaultOutputHandler.java
deleted file mode 100644
index 907a494..0000000
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/DefaultOutputHandler.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.asterix.event.management;
-
-import org.apache.asterix.event.schema.pattern.Event;
-
-public class DefaultOutputHandler implements IOutputHandler {
-
- @Override
- public OutputAnalysis reportEventOutput(Event event, String output) {
- return new OutputAnalysis(true, null);
- }
-
-}
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ErrorHandler.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ErrorHandler.java
deleted file mode 100644
index fb2d1b7..0000000
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/management/ErrorHandler.java
+++ /dev/null
@@ -1,23 +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 ErrorHandler {
-
-}
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
index 4587756..ebeea63 100644
--- 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
@@ -35,7 +35,6 @@
public class EventExecutor {
- public static final String EVENTS_DIR = "events";
private static final String EXECUTE_SCRIPT = "execute.sh";
private static final String IP_LOCATION = "IP_LOCATION";
private static final String CLUSTER_ENV = "ENV";
@@ -49,7 +48,7 @@
pargs.add("/bin/bash");
pargs.add(client.getEventsHomeDir() + File.separator + AsterixEventServiceUtil.EVENT_DIR + File.separator
+ EXECUTE_SCRIPT);
- StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getClusterIp() + " ");
+ 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) {
@@ -59,41 +58,11 @@
envBuffer.append(p.getKey() + "=" + val + " ");
} else if (p.getKey().equals(EventUtil.NC_JAVA_OPTS)) {
if (!isMasterNode) {
- 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.contains("-Xdebug")) {
- builder.append(
- (" " + "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address="
- + debugPort));
- }
- }
- builder.append("\"");
- envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
+ appendJavaOpts(node, envBuffer, p);
}
} else if (p.getKey().equals(EventUtil.CC_JAVA_OPTS)) {
if (isMasterNode) {
- 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.contains("-Xdebug")) {
- builder.append(
- (" " + "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address="
- + debugPort));
- }
- }
- builder.append("\"");
- envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
+ appendJavaOpts(node, envBuffer, p);
}
} else if (p.getKey().equals("LOG_DIR")) {
String val = node.getLogDir() == null ? p.getValue() : node.getLogDir();
@@ -106,7 +75,7 @@
pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername());
}
- StringBuffer argBuffer = new StringBuffer();
+ StringBuilder argBuffer = new StringBuilder();
if (args != null && args.size() > 0) {
for (String arg : args) {
argBuffer.append(arg + " ");
@@ -118,7 +87,7 @@
pb.environment().put(CLUSTER_ENV, envBuffer.toString());
pb.environment().put(SCRIPT, script);
pb.environment().put(ARGS, argBuffer.toString());
- pb.environment().put(DAEMON, isDaemon ? "true" : "false");
+ pb.environment().put(DAEMON, Boolean.toString(isDaemon));
Process p = pb.start();
if (!isDaemon) {
@@ -132,4 +101,21 @@
}
}
}
+
+ 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(" ");
+ }
}
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
index e0e5bc4..29b855d 100644
--- 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
@@ -143,10 +143,6 @@
return interval;
}
- public long getInitialDelay() {
- return initialDelay;
- }
-
public Pattern getPattern() {
return pattern;
}
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
index 57648b8..55e0780 100644
--- 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
@@ -41,17 +41,11 @@
public class EventUtil {
public static final String EVENTS_DIR = "events";
- public static final String CLUSTER_CONF = "config/cluster.xml";
- public static final String PATTERN_CONF = "config/pattern.xml";
public static final DateFormat dateFormat = 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";
- private static final String CLUSTER_ENV = "ENV";
- private static final String SCRIPT = "SCRIPT";
- private static final String ARGS = "ARGS";
- private static final String EXECUTE_SCRIPT = "events/execute.sh";
public static Cluster getCluster(String clusterConfigurationPath) throws JAXBException {
File file = new File(clusterConfigurationPath);
@@ -201,7 +195,7 @@
return node;
}
}
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append(EventDriver.CLIENT_NODE.getId() + ",");
buffer.append(cluster.getMasterNode().getId() + ",");
for (Node v : cluster.getNode()) {
@@ -211,27 +205,6 @@
throw new IllegalArgumentException("Unknown node id :" + nodeid + " valid ids:" + buffer);
}
- public static void executeEventScript(Node node, String script, List<String> args, Cluster cluster)
- throws IOException, InterruptedException {
- List<String> pargs = new ArrayList<String>();
- pargs.add("/bin/bash");
- pargs.add(EventDriver.getEventsDir() + "/" + EXECUTE_SCRIPT);
- StringBuffer argBuffer = new StringBuffer();
- String env = EventDriver.getStringifiedEnv(cluster) + " " + IP_LOCATION + "=" + node.getClusterIp();
- if (args != null) {
- for (String arg : args) {
- argBuffer.append(arg + " ");
- }
- }
- ProcessBuilder pb = new ProcessBuilder(pargs);
- pb.environment().putAll(EventDriver.getEnvironment());
- pb.environment().put(IP_LOCATION, node.getClusterIp());
- pb.environment().put(CLUSTER_ENV, env);
- pb.environment().put(SCRIPT, script);
- pb.environment().put(ARGS, argBuffer.toString());
- pb.start();
- }
-
public static void executeLocalScript(Node node, String script, List<String> args) throws IOException,
InterruptedException {
List<String> pargs = new ArrayList<String>();
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
index e6c6986..f824d5b 100644
--- 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
@@ -66,10 +66,6 @@
this.backupInfo = new ArrayList<BackupInfo>();
}
- public Date getModifiedTimestamp() {
- return stateChangeTimestamp;
- }
-
public State getState() {
return state;
}
@@ -87,14 +83,6 @@
return name;
}
- public Date getCreatedTimestamp() {
- return createdTimestamp;
- }
-
- public Date getStateChangeTimestamp() {
- return stateChangeTimestamp;
- }
-
public void setStateChangeTimestamp(Date stateChangeTimestamp) {
this.stateChangeTimestamp = stateChangeTimestamp;
}
@@ -112,7 +100,7 @@
}
public String getDescription(boolean detailed) {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("Name:" + name + "\n");
buffer.append("Created:" + createdTimestamp + "\n");
@@ -150,15 +138,11 @@
return "http://" + cluster.getMasterNode().getClientIp() + ":" + webPort;
}
- public AsterixRuntimeState getAsterixRuntimeState() {
- return runtimeState;
- }
-
public void setAsterixRuntimeStates(AsterixRuntimeState runtimeState) {
this.runtimeState = runtimeState;
}
- private void addDetailedInformation(StringBuffer buffer) {
+ private void addDetailedInformation(StringBuilder buffer) {
buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getClusterIp()
+ "\n");
for (Node node : cluster.getNode()) {
@@ -196,7 +180,7 @@
private String getIndentation(String name, int lenMax) {
int len = name.length();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for (int i = 0; i < lenMax - len; i++) {
buf.append(" ");
}
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
index 38bb7a9..ae10cd7 100644
--- 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
@@ -58,7 +58,6 @@
public String toString() {
return id + " " + date + " " + "(" + getBackupType() + ")" + " " + "[ " + this.getBackupConf().getBackupDir()
+ " ]";
-
}
public BackupType getBackupType() {
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
index f266b84..9702ceb 100644
--- 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
@@ -35,18 +35,10 @@
this.processId = processId;
}
- public String getProcessName() {
- return processName;
- }
-
public String getHost() {
return host;
}
- public int getProcessId() {
- return processId;
- }
-
public String getNodeId() {
return nodeId;
}
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventService.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventService.java
index 55a9200..f95b934 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventService.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventService.java
@@ -21,13 +21,12 @@
import java.io.File;
import java.io.FileFilter;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
import org.apache.asterix.event.error.OutputHandler;
import org.apache.asterix.event.management.AsterixEventServiceClient;
import org.apache.asterix.event.schema.cluster.Cluster;
import org.apache.asterix.installer.schema.conf.Configuration;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
public class AsterixEventService {
@@ -46,15 +45,12 @@
public static AsterixEventServiceClient getAsterixEventServiceClient(Cluster cluster, boolean transferArtifacts,
boolean dryRun) throws Exception {
- AsterixEventServiceClient client = new AsterixEventServiceClient(configuration, eventHome, cluster,
- transferArtifacts, dryRun, OutputHandler.INSTANCE);
- return client;
+ return new AsterixEventServiceClient(configuration, eventHome, cluster, transferArtifacts, dryRun,
+ OutputHandler.INSTANCE);
}
public static AsterixEventServiceClient getAsterixEventServiceClient(Cluster cluster) throws Exception {
- AsterixEventServiceClient client = new AsterixEventServiceClient(configuration, eventHome, cluster, false,
- false, OutputHandler.INSTANCE);
- return client;
+ return new AsterixEventServiceClient(configuration, eventHome, cluster, false, false, OutputHandler.INSTANCE);
}
private static String initBinary(final String fileNamePattern) {
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventServiceUtil.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventServiceUtil.java
index 02c06dc..9b22396 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventServiceUtil.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/AsterixEventServiceUtil.java
@@ -65,33 +65,25 @@
public class AsterixEventServiceUtil {
public static final String TXN_LOG_DIR = "txnLogs";
- public static final String TXN_LOG_DIR_KEY_SUFFIX = "txnLogDir";
public static final String ASTERIX_CONFIGURATION_FILE = "asterix-configuration.xml";
- public static final String TXN_LOG_CONFIGURATION_FILE = "log.properties";
public static final String CLUSTER_CONFIGURATION_FILE = "cluster.xml";
- public static final String ASTERIX_DIR = "asterix";
public static final String EVENT_DIR = "events";
- public static final String DEFAULT_ASTERIX_CONFIGURATION_PATH = "conf" + File.separator + File.separator
- + "asterix-configuration.xml";
public static final int CLUSTER_NET_PORT_DEFAULT = 1098;
public static final int CLIENT_NET_PORT_DEFAULT = 1099;
public static final int HTTP_PORT_DEFAULT = 8888;
- public static final int WEB_INTERFACE_PORT_DEFAULT = 19001;
- public static final String MANAGIX_INTERNAL_DIR = ".installer";
public static final String MANAGIX_CONF_XML = "conf" + File.separator + "managix-conf.xml";
private static final int BUFFER_SIZE = 4096;
public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster,
- AsterixConfiguration asterixConfiguration) throws FileNotFoundException, IOException {
+ AsterixConfiguration asterixConfiguration) throws IOException {
Node metadataNode = getMetadataNode(asterixInstanceName, cluster);
String asterixZipName = asterixZipName();
String asterixVersion = asterixZipName.substring("asterix-server-".length(),
asterixZipName.indexOf("-binary-assembly"));
- AsterixInstance instance = new AsterixInstance(asterixInstanceName, cluster, asterixConfiguration,
+ return new AsterixInstance(asterixInstanceName, cluster, asterixConfiguration,
metadataNode.getId(), asterixVersion);
- return instance;
}
public static void createAsterixZip(AsterixInstance asterixInstance)
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ServiceProvider.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ServiceProvider.java
index 7606a25..ab421fd 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ServiceProvider.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ServiceProvider.java
@@ -24,7 +24,6 @@
private static ILookupService lookupService = new ZooKeeperService();
private ServiceProvider() {
-
}
public ILookupService getLookupService() {
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ZooKeeperService.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ZooKeeperService.java
index a10b5ea..ee80894 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ZooKeeperService.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/service/ZooKeeperService.java
@@ -67,7 +67,7 @@
public boolean isRunning(Configuration conf) throws Exception {
List<String> servers = conf.getZookeeper().getServers().getServer();
int clientPort = conf.getZookeeper().getClientPort().intValue();
- StringBuffer connectionString = new StringBuffer();
+ StringBuilder connectionString = new StringBuilder();
for (String serverAddress : servers) {
connectionString.append(serverAddress);
connectionString.append(":");
@@ -101,7 +101,7 @@
ZookeeperUtil.writeConfiguration(ZOO_KEEPER_CONFIG, conf, ZOOKEEPER_LEADER_CONN_PORT,
ZOOKEEPER_LEADER_ELEC_PORT);
String initScript = ZOOKEEPER_HOME + File.separator + "bin" + File.separator + "zk.init";
- StringBuffer cmdBuffer = new StringBuffer();
+ StringBuilder cmdBuffer = new StringBuilder();
cmdBuffer.append(initScript + " ");
cmdBuffer.append(conf.getZookeeper().getHomeDir() + " ");
cmdBuffer.append(conf.getZookeeper().getServers().getJavaHome() + " ");
@@ -137,7 +137,7 @@
LOGGER.debug("Stopping ZooKeeper running at " + zkConnectionString);
}
String stopScript = ZOOKEEPER_HOME + File.separator + "bin" + File.separator + "stop_zk";
- StringBuffer cmdBuffer = new StringBuffer();
+ StringBuilder cmdBuffer = new StringBuilder();
cmdBuffer.append(stopScript + " ");
cmdBuffer.append(conf.getZookeeper().getHomeDir() + " ");
List<String> zkServers = conf.getZookeeper().getServers().getServer();
@@ -282,7 +282,7 @@
public static void writeConfiguration(String zooKeeperConfigPath, Configuration conf, int leaderConnPort,
int leaderElecPort) throws IOException {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("tickTime=1000" + "\n");
buffer.append("dataDir=" + conf.getZookeeper().getHomeDir() + File.separator + "data" + "\n");
buffer.append("clientPort=" + conf.getZookeeper().getClientPort().intValue() + "\n");
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
index 1780a51..9c6725b 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
@@ -54,8 +54,6 @@
private PatternCreator() {
}
- private ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
-
private void addInitialDelay(Pattern p, int delay, String unit) {
Delay d = new Delay(new Value(null, Integer.toString(delay)), unit);
p.setDelay(d);
@@ -102,26 +100,6 @@
return new Patterns(ps);
}
- public Patterns getStopCommandPattern(String asterixInstanceName) throws Exception {
- List<Pattern> ps = new ArrayList<>();
- AsterixInstance asterixInstance = lookupService.getAsterixInstance(asterixInstanceName);
- Cluster cluster = asterixInstance.getCluster();
-
- String ccLocation = cluster.getMasterNode().getId();
- Pattern createCC = createCCStopPattern(ccLocation);
- addInitialDelay(createCC, 5, "sec");
- ps.add(createCC);
-
- int nodeControllerIndex = 1;
- for (Node node : cluster.getNode()) {
- Pattern createNC = createNCStopPattern(node.getId(), asterixInstanceName + "_" + nodeControllerIndex);
- ps.add(createNC);
- nodeControllerIndex++;
- }
-
- return new Patterns(ps);
- }
-
public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
BackupType backupType = BackupInfo.getBackupType(backupConf);
Patterns patterns = null;
@@ -600,7 +578,7 @@
return new Patterns(ps);
}
- public Patterns getGenerateLogPattern(String asterixInstanceName, Cluster cluster, String outputDir) {
+ public Patterns getGenerateLogPattern(Cluster cluster, String outputDir) {
List<Pattern> patternList = new ArrayList<>();
Map<String, String> nodeLogs = new HashMap<>();
diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java
index b4ea96b..1e00d70 100644
--- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java
+++ b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java
@@ -58,7 +58,7 @@
throw new InstallerException("Unable to create output directory:" + outputDirPath);
}
}
- Patterns transferLogPattern = pc.getGenerateLogPattern(asterixInstanceName, instance.getCluster(),
+ Patterns transferLogPattern = pc.getGenerateLogPattern(instance.getCluster(),
outputDirPath);
eventrixClient.submit(transferLogPattern);
File outputDirFile = new File(outputDirPath);