Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/1642#discussion_r77260851
--- Diff:
storm-core/src/jvm/org/apache/storm/daemon/supervisor/BasicContainer.java ---
@@ -0,0 +1,644 @@
+/**
+ * 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.storm.daemon.supervisor;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.storm.Config;
+import org.apache.storm.container.ResourceIsolationInterface;
+import org.apache.storm.generated.LocalAssignment;
+import org.apache.storm.generated.ProfileAction;
+import org.apache.storm.generated.ProfileRequest;
+import org.apache.storm.generated.StormTopology;
+import org.apache.storm.generated.WorkerResources;
+import org.apache.storm.utils.ConfigUtils;
+import org.apache.storm.utils.LocalState;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
+/**
+ * A container that runs processes on the local box.
+ */
+public class BasicContainer extends Container {
+ private static final Logger LOG =
LoggerFactory.getLogger(BasicContainer.class);
+ private static final FilenameFilter jarFilter = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
+ }
+ };
+ private static final Joiner CPJ =
+ Joiner.on(Utils.CLASS_PATH_SEPARATOR).skipNulls();
+
+ protected final LocalState _localState;
+ protected final String _profileCmd;
+ protected volatile boolean _exitedEarly = false;
+
+ private class ProcessExitCallback implements ExitCodeCallback {
+ private final String _logPrefix;
+
+ public ProcessExitCallback(String logPrefix) {
+ _logPrefix = logPrefix;
+ }
+
+ @Override
+ public void call(int exitCode) {
+ LOG.info("{} exited with code: {}", _logPrefix, exitCode);
+ _exitedEarly = true;
+ }
+ }
+
+ //For testing purposes
+ public BasicContainer(AdvancedFSOps ops, int port, LocalAssignment
assignment,
+ Map<String, Object> conf, Map<String, Object> topoConf, String
supervisorId,
+ ResourceIsolationInterface resourceIsolationManager,
LocalState localState,
+ String profileCmd) throws IOException {
+ super(ops, port, assignment, conf, topoConf, supervisorId,
resourceIsolationManager);
+ _localState = localState;
+ _profileCmd = profileCmd;
+ }
+
+ public BasicContainer(int port, LocalAssignment assignment,
Map<String, Object> conf, String supervisorId,
+ LocalState localState, ResourceIsolationInterface
resourceIsolationManager, boolean recover)
+ throws IOException {
+ super(port, assignment, conf, supervisorId,
resourceIsolationManager);
+ _localState = localState;
+
+ if (recover) {
+ synchronized (localState) {
+ String wid = null;
+ Map<String, Integer> workerToPort =
localState.getApprovedWorkers();
+ for (Map.Entry<String, Integer> entry :
workerToPort.entrySet()) {
+ if (port == entry.getValue().intValue()) {
+ wid = entry.getKey();
+ }
+ }
+ if (wid == null) {
+ throw new ContainerRecoveryException("Could not find
worker id for " + port + " " + assignment);
+ }
+ LOG.info("Recovered Worker {}", wid);
+ _workerId = wid;
+ }
+ } else {
+ createNewWorkerId();
+ }
+
+ String stormHome = System.getProperty("storm.home");
+ _profileCmd = stormHome + Utils.FILE_PATH_SEPARATOR + "bin" +
Utils.FILE_PATH_SEPARATOR
+ + conf.get(Config.WORKER_PROFILER_COMMAND);
+ }
+
+ public BasicContainer(String workerId, Map<String, Object> conf,
String supervisorId,
+ ResourceIsolationInterface resourceIsolationManager) throws
IOException {
+ super(-1, null, conf, supervisorId, resourceIsolationManager);
+ _localState = null;
+ _workerId = workerId;
+ _profileCmd = null;
+ }
+
+ /**
+ * Create a new worker ID for this process and store in in this object
and
+ * in the local state. Never call this if a worker is currently up
and running.
--- End diff --
done
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---