asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject [3/6] asterixdb git commit: Unify structure of Cluster Controller and Node Controller
Date Fri, 10 Mar 2017 08:14:22 GMT
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
index 500ca30..c3b7348 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/LSMRTreeLocalResourceMetadata.java
@@ -23,7 +23,7 @@ import java.util.Map;
 
 import org.apache.asterix.common.api.IAppRuntimeContext;
 import org.apache.asterix.common.transactions.Resource;
-import org.apache.hyracks.api.application.INCApplicationContext;
+import org.apache.hyracks.api.application.INCServiceContext;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 import org.apache.hyracks.api.dataflow.value.ILinearizeComparatorFactory;
 import org.apache.hyracks.api.dataflow.value.ITypeTraits;
@@ -82,21 +82,21 @@ public class LSMRTreeLocalResourceMetadata extends Resource {
     }
 
     @Override
-    public ILSMIndex createIndexInstance(INCApplicationContext appCtx, LocalResource resource)
+    public ILSMIndex createIndexInstance(INCServiceContext serviceCtx, LocalResource resource)
             throws HyracksDataException {
-        IAppRuntimeContext runtimeContextProvider = (IAppRuntimeContext) appCtx.getApplicationObject();
-        IIOManager ioManager = runtimeContextProvider.getIOManager();
+        IAppRuntimeContext appCtx = (IAppRuntimeContext) serviceCtx.getApplicationContext();
+        IIOManager ioManager = appCtx.getIOManager();
         FileReference file = ioManager.resolve(resource.getPath());
         int ioDeviceNum = Resource.getIoDeviceNum(ioManager, file.getDeviceHandle());
         List<IVirtualBufferCache> virtualBufferCaches =
-                runtimeContextProvider.getDatasetLifecycleManager().getVirtualBufferCaches(datasetId(), ioDeviceNum);
+                appCtx.getDatasetLifecycleManager().getVirtualBufferCaches(datasetId(), ioDeviceNum);
         try {
             return LSMRTreeUtils.createLSMTreeWithAntiMatterTuples(ioManager, virtualBufferCaches, file,
-                    runtimeContextProvider.getBufferCache(), runtimeContextProvider.getFileMapManager(), typeTraits,
+                    appCtx.getBufferCache(), appCtx.getFileMapManager(), typeTraits,
                     rtreeCmpFactories, btreeCmpFactories, valueProviderFactories, rtreePolicyType,
                     mergePolicyFactory.createMergePolicy(mergePolicyProperties,
-                            runtimeContextProvider.getDatasetLifecycleManager()),
-                    opTrackerProvider.getOperationTracker(appCtx), runtimeContextProvider.getLSMIOScheduler(),
+                            appCtx.getDatasetLifecycleManager()),
+                    opTrackerProvider.getOperationTracker(serviceCtx), appCtx.getLSMIOScheduler(),
                     ioOpCallbackFactory.createIoOpCallback(), linearizeCmpFactory, rtreeFields, filterTypeTraits,
                     filterCmpFactories, filterFields, true, isPointMBR, metadataPageManagerFactory);
         } catch (TreeIndexException e) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/runtime/CommitRuntime.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/runtime/CommitRuntime.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/runtime/CommitRuntime.java
index 90f6bbf..b114527 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/runtime/CommitRuntime.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/runtime/CommitRuntime.java
@@ -65,10 +65,10 @@ public class CommitRuntime extends AbstractOneInputOneOutputOneFramePushRuntime
     public CommitRuntime(IHyracksTaskContext ctx, JobId jobId, int datasetId, int[] primaryKeyFields,
             boolean isTemporaryDatasetWriteJob, boolean isWriteTransaction, int resourcePartition, boolean isSink) {
         this.ctx = ctx;
-        IAppRuntimeContext runtimeCtx =
-                (IAppRuntimeContext) ctx.getJobletContext().getApplicationContext().getApplicationObject();
-        this.transactionManager = runtimeCtx.getTransactionSubsystem().getTransactionManager();
-        this.logMgr = runtimeCtx.getTransactionSubsystem().getLogManager();
+        IAppRuntimeContext appCtx =
+                (IAppRuntimeContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
+        this.transactionManager = appCtx.getTransactionSubsystem().getTransactionManager();
+        this.logMgr = appCtx.getTransactionSubsystem().getLogManager();
         this.jobId = jobId;
         this.datasetId = datasetId;
         this.primaryKeyFields = primaryKeyFields;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/asterixdb/asterix-yarn/pom.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-yarn/pom.xml b/asterixdb/asterix-yarn/pom.xml
index e8c1895..66e3a96 100644
--- a/asterixdb/asterix-yarn/pom.xml
+++ b/asterixdb/asterix-yarn/pom.xml
@@ -191,7 +191,6 @@
             <usedDependency>commons-lang:commons-lang</usedDependency>
             <usedDependency>commons-logging:commons-logging-api</usedDependency>
             <usedDependency>commons-net:commons-net</usedDependency>
-            <usedDependency>org.apache.asterix:asterix-app</usedDependency>
             <usedDependency>org.apache.asterix:asterix-events</usedDependency>
             <usedDependency>org.apache.asterix:asterix-runtime</usedDependency>
             <usedDependency>org.apache.asterix:asterix-server</usedDependency>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java b/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
index b4aeeb1..47cf3b3 100644
--- a/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
+++ b/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
@@ -51,6 +51,8 @@ import org.apache.asterix.common.utils.StorageConstants;
 import org.apache.asterix.event.schema.yarnCluster.Cluster;
 import org.apache.asterix.event.schema.yarnCluster.MasterNode;
 import org.apache.asterix.event.schema.yarnCluster.Node;
+import org.apache.asterix.hyracks.bootstrap.CCApplication;
+import org.apache.asterix.hyracks.bootstrap.NCApplication;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.GnuParser;
 import org.apache.commons.cli.HelpFormatter;
@@ -152,7 +154,7 @@ public class AsterixApplicationMaster {
     //Tells us whether the Cluster Controller is up so we can safely start some Node Controllers
     private AtomicBoolean ccUp = new AtomicBoolean();
     private AtomicBoolean ccStarted = new AtomicBoolean();
-    private Queue<Node> pendingNCs = new ArrayDeque<Node>();
+    private Queue<Node> pendingNCs = new ArrayDeque<>();
 
     //HDFS path to AsterixDB distributable zip
     private String asterixZipPath = "";
@@ -176,7 +178,7 @@ public class AsterixApplicationMaster {
     private int numTotalContainers = 0;
 
     // Set the local resources
-    private Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
+    private Map<String, LocalResource> localResources = new HashMap<>();
 
     private Cluster clusterDesc = null;
     private MasterNode cC = null;
@@ -196,7 +198,7 @@ public class AsterixApplicationMaster {
     private boolean initial = false;
 
     // Launch threads
-    private List<Thread> launchThreads = new CopyOnWriteArrayList<Thread>();
+    private List<Thread> launchThreads = new CopyOnWriteArrayList<>();
 
     public static void main(String[] args) {
 
@@ -548,8 +550,9 @@ public class AsterixApplicationMaster {
         for (Node node : cl.getNode()) {
             InetAddress nodeIp = InetAddress.getByName(node.getClusterIp());
             LOG.info(nodeIp + "?=" + containerIp);
-            if (nodeIp.equals(containerIp))
+            if (nodeIp.equals(containerIp)) {
                 return node;
+            }
         }
         //if we find nothing, this is bad...
         throw new java.net.UnknownHostException("Could not resolve container" + containerHost + " to node");
@@ -626,12 +629,14 @@ public class AsterixApplicationMaster {
             if (fs.exists(p)) {
                 FileStatus[] dataverses = fs.listStatus(p);
                 for (FileStatus d : dataverses) {
-                    if (!d.isDirectory())
+                    if (!d.isDirectory()) {
                         throw new IOException("Library configuration directory structure is incorrect");
+                    }
                     FileStatus[] libraries = fs.listStatus(d.getPath());
                     for (FileStatus l : libraries) {
-                        if (l.isDirectory())
+                        if (l.isDirectory()) {
                             throw new IOException("Library configuration directory structure is incorrect");
+                        }
                         LocalResource lr = Records.newRecord(LocalResource.class);
                         lr.setResource(ConverterUtils.getYarnUrlFromURI(l.getPath().toUri()));
                         lr.setSize(l.getLen());
@@ -767,6 +772,7 @@ public class AsterixApplicationMaster {
      * is running.
      */
     private class RMCallbackHandler implements AMRMClientAsync.CallbackHandler {
+        @Override
         public void onContainersCompleted(List<ContainerStatus> completedContainers) {
             LOG.info("Got response from RM for container ask, completedCnt=" + completedContainers.size());
             for (ContainerStatus containerStatus : completedContainers) {
@@ -794,10 +800,12 @@ public class AsterixApplicationMaster {
             }
             //stop infinite looping of run()
             if (numCompletedContainers.get() + numFailedContainers.get() == numAllocatedContainers.get()
-                    && doneAllocating)
+                    && doneAllocating) {
                 done = true;
+            }
         }
 
+        @Override
         public void onContainersAllocated(List<Container> allocatedContainers) {
             LOG.info("Got response from RM for container ask, allocatedCnt=" + allocatedContainers.size());
             numAllocatedContainers.addAndGet(allocatedContainers.size());
@@ -850,15 +858,18 @@ public class AsterixApplicationMaster {
         /**
          * Ask the processes on the container to gracefully exit.
          */
+        @Override
         public void onShutdownRequest() {
             LOG.info("AM shutting down per request");
             done = true;
         }
 
+        @Override
         public void onNodesUpdated(List<NodeReport> updatedNodes) {
             //TODO: This will become important when we deal with what happens if an NC dies
         }
 
+        @Override
         public float getProgress() {
             //return half way because progress is basically meaningless for us
             if (!doneAllocating) {
@@ -867,6 +878,7 @@ public class AsterixApplicationMaster {
             return (float) 0.5;
         }
 
+        @Override
         public void onError(Throwable arg0) {
             LOG.error("Fatal Error recieved by AM: " + arg0);
             done = true;
@@ -875,12 +887,13 @@ public class AsterixApplicationMaster {
 
     private class NMCallbackHandler implements NMClientAsync.CallbackHandler {
 
-        private ConcurrentMap<ContainerId, Container> containers = new ConcurrentHashMap<ContainerId, Container>();
+        private ConcurrentMap<ContainerId, Container> containers = new ConcurrentHashMap<>();
 
         public void addContainer(ContainerId containerId, Container container) {
             containers.putIfAbsent(containerId, container);
         }
 
+        @Override
         public void onContainerStopped(ContainerId containerId) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Succeeded to stop Container " + containerId);
@@ -888,12 +901,14 @@ public class AsterixApplicationMaster {
             containers.remove(containerId);
         }
 
+        @Override
         public void onContainerStatusReceived(ContainerId containerId, ContainerStatus containerStatus) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Container Status: id=" + containerId + ", status=" + containerStatus);
             }
         }
 
+        @Override
         public void onContainerStarted(ContainerId containerId, Map<String, ByteBuffer> allServiceResponse) {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Succeeded to start Container " + containerId);
@@ -904,15 +919,18 @@ public class AsterixApplicationMaster {
             }
         }
 
+        @Override
         public void onStartContainerError(ContainerId containerId, Throwable t) {
             LOG.error("Failed to start Container " + containerId);
             containers.remove(containerId);
         }
 
+        @Override
         public void onGetContainerStatusError(ContainerId containerId, Throwable t) {
             LOG.error("Failed to query the status of Container " + containerId);
         }
 
+        @Override
         public void onStopContainerError(ContainerId containerId, Throwable t) {
             LOG.error("Failed to stop Container " + containerId);
             containers.remove(containerId);
@@ -946,6 +964,7 @@ public class AsterixApplicationMaster {
          * for shell command and eventually dispatches the container
          * start request to the CM.
          */
+        @Override
         public void run() {
             LOG.info("Setting up container launch container for containerid=" + container.getId());
             ContainerLaunchContext ctx = Records.newRecord(ContainerLaunchContext.class);
@@ -954,7 +973,7 @@ public class AsterixApplicationMaster {
 
             //Set the env variables to be setup in the env where the application master will be run
             LOG.info("Set the environment for the node");
-            Map<String, String> env = new HashMap<String, String>();
+            Map<String, String> env = new HashMap<>();
 
             // Add AppMaster.jar location to classpath
             // At some point we should not be required to add
@@ -1019,9 +1038,9 @@ public class AsterixApplicationMaster {
          * @return A list of the commands that should be executed
          */
         private List<String> produceStartCmd(Container container) {
-            List<String> commands = new ArrayList<String>();
+            List<String> commands = new ArrayList<>();
             // Set the necessary command to execute on the allocated container
-            List<CharSequence> vargs = new ArrayList<CharSequence>(5);
+            List<CharSequence> vargs = new ArrayList<>(5);
 
             vargs.add(JAVA_HOME + File.separator + "bin" + File.separator + "java");
             vargs.add("-classpath " + '\'' + ASTERIX_ZIP_NAME + File.separator + "repo" + File.separator + "*\'");
@@ -1032,7 +1051,7 @@ public class AsterixApplicationMaster {
                 //get our java opts
                 vargs.add(ccJavaOpts);
                 vargs.add(CC_CLASSNAME);
-                vargs.add("-app-class org.apache.asterix.hyracks.bootstrap.CCApplicationEntryPoint");
+                vargs.add("-app-class " + CCApplication.class.getName());
                 vargs.add("-address " + cC.getClusterIp());
                 vargs.add("-client-listen-address " + cC.getClientIp());
                 //pass CC optional parameters
@@ -1074,7 +1093,7 @@ public class AsterixApplicationMaster {
                     }
                     vargs.add(ncJavaOpts);
                     vargs.add(NC_CLASSNAME);
-                    vargs.add("-app-class org.apache.asterix.hyracks.bootstrap.NCApplicationEntryPoint");
+                    vargs.add("-app-class " + NCApplication.class.getName());
                     vargs.add("-node-id " + local.getId());
                     vargs.add("-cluster-address " + cC.getClusterIp());
                     vargs.add("-iodevices " + iodevice);
@@ -1126,8 +1145,8 @@ public class AsterixApplicationMaster {
             StringBuilder classPathEnv = new StringBuilder("").append("*");
             classPathEnv.append(File.pathSeparatorChar).append("log4j.properties");
 
-            List<String> commands = new ArrayList<String>();
-            Vector<CharSequence> vargs = new Vector<CharSequence>(5);
+            List<String> commands = new ArrayList<>();
+            Vector<CharSequence> vargs = new Vector<>(5);
             vargs.add(JAVA_HOME + File.separator + "bin" + File.separator + "java");
             vargs.add("-cp " + classPathEnv.toString());
             vargs.add(OBLITERATOR_CLASSNAME);
@@ -1177,8 +1196,8 @@ public class AsterixApplicationMaster {
             }
             classPathEnv.append(File.pathSeparatorChar).append("." + File.separator + "log4j.properties");
 
-            List<String> commands = new ArrayList<String>();
-            Vector<CharSequence> vargs = new Vector<CharSequence>(5);
+            List<String> commands = new ArrayList<>();
+            Vector<CharSequence> vargs = new Vector<>(5);
             vargs.add(JAVA_HOME + File.separator + "bin" + File.separator + "java");
             vargs.add("-cp " + classPathEnv.toString());
             vargs.add(HDFS_BACKUP_CLASSNAME);
@@ -1230,7 +1249,7 @@ public class AsterixApplicationMaster {
 
         private List<String> produceRestoreCommand(Container container) {
             if (containerIsCC(container)) {
-                List<String> blank = new ArrayList<String>();
+                List<String> blank = new ArrayList<>();
                 blank.add("");
                 return blank;
             }
@@ -1260,8 +1279,8 @@ public class AsterixApplicationMaster {
             }
             classPathEnv.append(File.pathSeparatorChar).append("." + File.separator + "log4j.properties");
 
-            List<String> commands = new ArrayList<String>();
-            Vector<CharSequence> vargs = new Vector<CharSequence>(5);
+            List<String> commands = new ArrayList<>();
+            Vector<CharSequence> vargs = new Vector<>(5);
             vargs.add(JAVA_HOME + File.separator + "bin" + File.separator + "java");
             vargs.add("-cp " + classPathEnv.toString());
             vargs.add(HDFS_BACKUP_CLASSNAME);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplication.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplication.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplication.java
new file mode 100644
index 0000000..3ce314f
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplication.java
@@ -0,0 +1,38 @@
+/*
+ * 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.hyracks.api.application;
+
+import org.apache.hyracks.api.config.IConfigManager;
+import org.kohsuke.args4j.OptionHandlerFilter;
+
+public interface IApplication {
+    void start(IServiceContext ctx, String[] args) throws Exception; //NOSONAR
+
+    void startupCompleted() throws Exception; //NOSONAR
+
+    void stop() throws Exception; //NOSONAR
+
+    void registerConfig(IConfigManager configManager);
+
+    Object getApplicationContext();
+
+    default OptionHandlerFilter getUsageFilter() {
+        return OptionHandlerFilter.PUBLIC;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplicationContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplicationContext.java
deleted file mode 100644
index c933d9d..0000000
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IApplicationContext.java
+++ /dev/null
@@ -1,60 +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.hyracks.api.application;
-
-import java.io.Serializable;
-import java.util.concurrent.ThreadFactory;
-
-import org.apache.hyracks.api.config.IApplicationConfig;
-import org.apache.hyracks.api.job.IJobSerializerDeserializerContainer;
-import org.apache.hyracks.api.messages.IMessageBroker;
-import org.apache.hyracks.api.service.IControllerService;
-
-/**
- * Base class of the {@link ICCApplicationContext} and the {@link INCApplicationContext}.
- *
- * @author vinayakb
- */
-public interface IApplicationContext {
-    /**
-     * Gets the distributed state that is made available to all the Application
-     * Contexts of this application in the cluster.
-     *
-     * @return
-     */
-    public Serializable getDistributedState();
-
-    public void setMessageBroker(IMessageBroker messageBroker);
-
-    public IMessageBroker getMessageBroker();
-
-    public IJobSerializerDeserializerContainer getJobSerializerDeserializerContainer();
-
-    public ThreadFactory getThreadFactory();
-
-    public void setThreadFactory(ThreadFactory threadFactory);
-
-    public IApplicationConfig getAppConfig();
-
-    /**
-     * @return The controller service which the application context belongs to.
-     */
-    public IControllerService getControllerService();
-
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplication.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplication.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplication.java
new file mode 100644
index 0000000..b105d24
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplication.java
@@ -0,0 +1,30 @@
+/*
+ * 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.hyracks.api.application;
+
+import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.api.job.resource.IJobCapacityController;
+
+public interface ICCApplication extends IApplication {
+
+    IJobCapacityController getJobCapacityController();
+
+    IHyracksClientConnection getHcc() throws Exception; //NOSONAR
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationContext.java
deleted file mode 100644
index 55cc5fa..0000000
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.api.application;
-
-import java.io.Serializable;
-
-import org.apache.hyracks.api.context.ICCContext;
-import org.apache.hyracks.api.job.IJobLifecycleListener;
-
-/**
- * Application Context at the Cluster Controller for an application.
- *
- * @author vinayakb
- */
-public interface ICCApplicationContext extends IApplicationContext {
-    /**
-     * Sets the state that must be distributed by the infrastructure to all the
-     * NC application contexts. Any state set by calling this method in the {@link ICCApplicationEntryPoint#start(ICCApplicationContext, String[])} call is made available to all the {@link INCApplicationContext} objects
-     * at each Node Controller. The state is then available to be inspected by
-     * the application at the NC during or after the {@link INCBootstrap#start()} call.
-     *
-     * @param state
-     *            The distributed state
-     */
-    void setDistributedState(Serializable state);
-
-    /**
-     * A listener that listens to Job Lifecycle events at the Cluster
-     * Controller.
-     *
-     * @param jobLifecycleListener
-     */
-    void addJobLifecycleListener(IJobLifecycleListener jobLifecycleListener);
-
-    /**
-     * A listener that listens to Cluster Lifecycle events at the Cluster
-     * Controller.
-     *
-     * @param clusterLifecycleListener
-     */
-    void addClusterLifecycleListener(IClusterLifecycleListener clusterLifecycleListener);
-
-    /**
-     * Get the Cluster Controller Context.
-     *
-     * @return The Cluster Controller Context.
-     */
-    ICCContext getCCContext();
-
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java
deleted file mode 100644
index 4f6f450..0000000
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java
+++ /dev/null
@@ -1,39 +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.hyracks.api.application;
-
-import org.apache.hyracks.api.config.IConfigManager;
-import org.apache.hyracks.api.job.resource.IJobCapacityController;
-import org.kohsuke.args4j.OptionHandlerFilter;
-
-public interface ICCApplicationEntryPoint {
-    void start(ICCApplicationContext ccAppCtx, String[] args) throws Exception;
-
-    void stop() throws Exception;
-
-    void startupCompleted() throws Exception;
-
-    IJobCapacityController getJobCapacityController();
-
-    void registerConfig(IConfigManager configManager);
-
-    default OptionHandlerFilter getUsageFilter() {
-        return OptionHandlerFilter.PUBLIC;
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCServiceContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCServiceContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCServiceContext.java
new file mode 100644
index 0000000..c0e9834
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCServiceContext.java
@@ -0,0 +1,64 @@
+/*
+ * 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.hyracks.api.application;
+
+import java.io.Serializable;
+
+import org.apache.hyracks.api.context.ICCContext;
+import org.apache.hyracks.api.job.IJobLifecycleListener;
+
+/**
+ * Service Context at the Cluster Controller for an application.
+ */
+public interface ICCServiceContext extends IServiceContext {
+    /**
+     * Sets the state that must be distributed by the infrastructure
+     * to all the {@link org.apache.hyracks.api.application.INCServiceContext}.
+     * Any state set by calling this method in the {@link ICCApplication#start(ICCServiceContext, String[])} call
+     * is made available to all the {@link INCServiceContext} objects at each Node Controller.
+     *
+     * @param state
+     *            The distributed state
+     */
+    void setDistributedState(Serializable state);
+
+    /**
+     * A listener that listens to Job Lifecycle events at the Cluster
+     * Controller.
+     *
+     * @param jobLifecycleListener
+     */
+    void addJobLifecycleListener(IJobLifecycleListener jobLifecycleListener);
+
+    /**
+     * A listener that listens to Cluster Lifecycle events at the Cluster
+     * Controller.
+     *
+     * @param clusterLifecycleListener
+     */
+    void addClusterLifecycleListener(IClusterLifecycleListener clusterLifecycleListener);
+
+    /**
+     * Get the Cluster Controller Context.
+     *
+     * @return The Cluster Controller Context.
+     */
+    ICCContext getCCContext();
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplication.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplication.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplication.java
new file mode 100644
index 0000000..44b1eb5
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplication.java
@@ -0,0 +1,26 @@
+/*
+ * 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.hyracks.api.application;
+
+import org.apache.hyracks.api.job.resource.NodeCapacity;
+
+public interface INCApplication extends IApplication {
+
+    NodeCapacity getCapacity();
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationContext.java
deleted file mode 100644
index ae25f88..0000000
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationContext.java
+++ /dev/null
@@ -1,94 +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.hyracks.api.application;
-
-import org.apache.hyracks.api.comm.IChannelInterfaceFactory;
-import org.apache.hyracks.api.io.IIOManager;
-import org.apache.hyracks.api.lifecycle.ILifeCycleComponentManager;
-import org.apache.hyracks.api.resources.memory.IMemoryManager;
-
-/**
- * Application Context at the Node Controller for an application.
- *
- * @author vinayakb
- */
-public interface INCApplicationContext extends IApplicationContext {
-    /**
-     * Gets the life cycle component manager of the Node Controller.
-     *
-     * @return
-     */
-    public ILifeCycleComponentManager getLifeCycleComponentManager();
-
-    /**
-     * Gets the node Id of the Node Controller.
-     *
-     * @return the Node Id.
-     */
-    public String getNodeId();
-
-    /**
-     * @return the IO Manager
-     */
-    public IIOManager getIoManager();
-
-    /**
-     * Set an object that can be later retrieved by the {@link #getApplicationObject()} call.
-     *
-     * @param object
-     *            Application Object
-     */
-    public void setApplicationObject(Object object);
-
-    /**
-     * Get the application object previously set by the {@link #setApplicationObject(Object)} call.
-     *
-     * @return Application Object
-     */
-    public Object getApplicationObject();
-
-    /**
-     * Get the memory manager at the node.
-     *
-     * @return Memory Manager
-     */
-    public IMemoryManager getMemoryManager();
-
-    /**
-     * Set the handler for state dumps.
-     *
-     * @param handler
-     */
-    public void setStateDumpHandler(IStateDumpHandler handler);
-
-    /**
-     * Set the application MessagingChannelInterfaceFactory
-     *
-     * @param interfaceFactory
-     */
-    public void setMessagingChannelInterfaceFactory(IChannelInterfaceFactory interfaceFactory);
-
-    /**
-     * Get the application MessagingChannelInterfaceFactory previously set by
-     * the {@link #setMessagingChannelInterfaceFactory(IChannelInterfaceFactory)} call.
-     *
-     * @return
-     */
-    public IChannelInterfaceFactory getMessagingChannelInterfaceFactory();
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationEntryPoint.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationEntryPoint.java
deleted file mode 100644
index a92cd4a..0000000
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCApplicationEntryPoint.java
+++ /dev/null
@@ -1,39 +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.hyracks.api.application;
-
-import org.apache.hyracks.api.config.IConfigManager;
-import org.apache.hyracks.api.job.resource.NodeCapacity;
-import org.kohsuke.args4j.OptionHandlerFilter;
-
-public interface INCApplicationEntryPoint {
-    void start(INCApplicationContext ncAppCtx, String[] args) throws Exception;
-
-    void notifyStartupComplete() throws Exception;
-
-    void stop() throws Exception;
-
-    NodeCapacity getCapacity();
-
-    void registerConfigOptions(IConfigManager configManager);
-
-    default OptionHandlerFilter getUsageFilter() {
-        return OptionHandlerFilter.PUBLIC;
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCServiceContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCServiceContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCServiceContext.java
new file mode 100644
index 0000000..d72cc01
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/INCServiceContext.java
@@ -0,0 +1,77 @@
+/*
+ * 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.hyracks.api.application;
+
+import org.apache.hyracks.api.comm.IChannelInterfaceFactory;
+import org.apache.hyracks.api.io.IIOManager;
+import org.apache.hyracks.api.lifecycle.ILifeCycleComponentManager;
+import org.apache.hyracks.api.resources.memory.IMemoryManager;
+
+/**
+ * Service Context at the Node Controller for an application.
+ */
+public interface INCServiceContext extends IServiceContext {
+    /**
+     * Gets the life cycle component manager of the Node Controller.
+     *
+     * @return
+     */
+    ILifeCycleComponentManager getLifeCycleComponentManager();
+
+    /**
+     * Gets the node Id of the Node Controller.
+     *
+     * @return the Node Id.
+     */
+    String getNodeId();
+
+    /**
+     * @return the IO Manager
+     */
+    IIOManager getIoManager();
+
+    /**
+     * Get the memory manager at the node.
+     *
+     * @return Memory Manager
+     */
+    IMemoryManager getMemoryManager();
+
+    /**
+     * Set the handler for state dumps.
+     *
+     * @param handler
+     */
+    void setStateDumpHandler(IStateDumpHandler handler);
+
+    /**
+     * Set the application MessagingChannelInterfaceFactory
+     *
+     * @param interfaceFactory
+     */
+    void setMessagingChannelInterfaceFactory(IChannelInterfaceFactory interfaceFactory);
+
+    /**
+     * Get the application MessagingChannelInterfaceFactory previously set by
+     * the {@link #setMessagingChannelInterfaceFactory(IChannelInterfaceFactory)} call.
+     *
+     * @return
+     */
+    IChannelInterfaceFactory getMessagingChannelInterfaceFactory();
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IServiceContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IServiceContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IServiceContext.java
new file mode 100644
index 0000000..bc3d7a1
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/IServiceContext.java
@@ -0,0 +1,58 @@
+/*
+ * 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.hyracks.api.application;
+
+import java.io.Serializable;
+import java.util.concurrent.ThreadFactory;
+
+import org.apache.hyracks.api.config.IApplicationConfig;
+import org.apache.hyracks.api.job.IJobSerializerDeserializerContainer;
+import org.apache.hyracks.api.messages.IMessageBroker;
+import org.apache.hyracks.api.service.IControllerService;
+
+/**
+ * Base interface of the {@link ICCServiceContext} and the {@link INCServiceContext}.
+ */
+public interface IServiceContext {
+    /**
+     * @return the distributed state that is made available to all the Application
+     *         Contexts of this application in the cluster.
+     */
+    Serializable getDistributedState();
+
+    void setMessageBroker(IMessageBroker messageBroker);
+
+    IMessageBroker getMessageBroker();
+
+    IJobSerializerDeserializerContainer getJobSerializerDeserializerContainer();
+
+    ThreadFactory getThreadFactory();
+
+    void setThreadFactory(ThreadFactory threadFactory);
+
+    IApplicationConfig getAppConfig();
+
+    /**
+     * @return The controller service which the application context belongs to.
+     */
+    IControllerService getControllerService();
+
+    Object getApplicationContext();
+
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
index da344aa..1c2b9b5 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
@@ -19,7 +19,6 @@
 package org.apache.hyracks.api.client.impl;
 
 import java.util.ArrayList;
-import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -29,7 +28,6 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.commons.lang3.tuple.Pair;
-
 import org.apache.hyracks.api.dataflow.ActivityId;
 import org.apache.hyracks.api.dataflow.ConnectorDescriptorId;
 import org.apache.hyracks.api.dataflow.IActivity;
@@ -53,12 +51,12 @@ public class JobActivityGraphBuilder implements IActivityGraphBuilder {
 
     private final Map<ConnectorDescriptorId, Pair<IActivity, Integer>> connectorConsumerMap;
 
-    public JobActivityGraphBuilder(JobSpecification jobSpec, EnumSet<JobFlag> jobFlags) {
-        activityOperatorMap = new HashMap<ActivityId, IOperatorDescriptor>();
+    public JobActivityGraphBuilder(JobSpecification jobSpec, Set<JobFlag> jobFlags) {
+        activityOperatorMap = new HashMap<>();
         jag = new JobActivityGraph();
         this.jobSpec = jobSpec;
-        connectorProducerMap = new HashMap<ConnectorDescriptorId, Pair<IActivity, Integer>>();
-        connectorConsumerMap = new HashMap<ConnectorDescriptorId, Pair<IActivity, Integer>>();
+        connectorProducerMap = new HashMap<>();
+        connectorConsumerMap = new HashMap<>();
     }
 
     public void addConnector(IConnectorDescriptor conn) {
@@ -116,7 +114,7 @@ public class JobActivityGraphBuilder implements IActivityGraphBuilder {
     private <K, V> void addToValueSet(Map<K, Set<V>> map, K n1, V n2) {
         Set<V> targets = map.get(n1);
         if (targets == null) {
-            targets = new HashSet<V>();
+            targets = new HashSet<>();
             map.put(n1, targets);
         }
         targets.add(n2);
@@ -132,7 +130,7 @@ public class JobActivityGraphBuilder implements IActivityGraphBuilder {
     private <K, V> void insertIntoIndexedMap(Map<K, List<V>> map, K key, int index, V value) {
         List<V> vList = map.get(key);
         if (vList == null) {
-            vList = new ArrayList<V>();
+            vList = new ArrayList<>();
             map.put(key, vList);
         }
         extend(vList, index);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobSpecificationActivityClusterGraphGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobSpecificationActivityClusterGraphGeneratorFactory.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobSpecificationActivityClusterGraphGeneratorFactory.java
index 9a908ab..61b4b4e 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobSpecificationActivityClusterGraphGeneratorFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobSpecificationActivityClusterGraphGeneratorFactory.java
@@ -18,11 +18,10 @@
  */
 package org.apache.hyracks.api.client.impl;
 
-import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.hyracks.api.application.ICCApplicationContext;
+import org.apache.hyracks.api.application.ICCServiceContext;
 import org.apache.hyracks.api.constraints.Constraint;
 import org.apache.hyracks.api.constraints.IConstraintAcceptor;
 import org.apache.hyracks.api.dataflow.IConnectorDescriptor;
@@ -53,7 +52,7 @@ public class JobSpecificationActivityClusterGraphGeneratorFactory implements IAc
 
     @Override
     public IActivityClusterGraphGenerator createActivityClusterGraphGenerator(JobId jobId,
-            final ICCApplicationContext ccAppCtx, EnumSet<JobFlag> jobFlags) throws HyracksException {
+            final ICCServiceContext ccServiceCtx, Set<JobFlag> jobFlags) throws HyracksException {
         final JobActivityGraphBuilder builder = new JobActivityGraphBuilder(spec, jobFlags);
         PlanUtils.visit(spec, new IConnectorDescriptorVisitor() {
             @Override
@@ -77,7 +76,7 @@ public class JobSpecificationActivityClusterGraphGeneratorFactory implements IAc
         acg.setJobletEventListenerFactory(spec.getJobletEventListenerFactory());
         acg.setConnectorPolicyAssignmentPolicy(spec.getConnectorPolicyAssignmentPolicy());
         acg.setUseConnectorPolicyForScheduling(spec.isUseConnectorPolicyForScheduling());
-        final Set<Constraint> constraints = new HashSet<Constraint>();
+        final Set<Constraint> constraints = new HashSet<>();
         final IConstraintAcceptor acceptor = new IConstraintAcceptor() {
             @Override
             public void addConstraint(Constraint constraint) {
@@ -87,14 +86,14 @@ public class JobSpecificationActivityClusterGraphGeneratorFactory implements IAc
         PlanUtils.visit(spec, new IOperatorDescriptorVisitor() {
             @Override
             public void visit(IOperatorDescriptor op) {
-                op.contributeSchedulingConstraints(acceptor, ccAppCtx);
+                op.contributeSchedulingConstraints(acceptor, ccServiceCtx);
             }
         });
         PlanUtils.visit(spec, new IConnectorDescriptorVisitor() {
             @Override
             public void visit(IConnectorDescriptor conn) {
                 conn.contributeSchedulingConstraints(acceptor, acg.getConnectorMap().get(conn.getConnectorId()),
-                        ccAppCtx);
+                        ccServiceCtx);
             }
         });
         constraints.addAll(spec.getUserConstraints());

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/context/IHyracksJobletContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/context/IHyracksJobletContext.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/context/IHyracksJobletContext.java
index 2ea657a..6eb0adb 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/context/IHyracksJobletContext.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/context/IHyracksJobletContext.java
@@ -18,7 +18,7 @@
  */
 package org.apache.hyracks.api.context;
 
-import org.apache.hyracks.api.application.INCApplicationContext;
+import org.apache.hyracks.api.application.INCServiceContext;
 import org.apache.hyracks.api.exceptions.HyracksException;
 import org.apache.hyracks.api.io.IWorkspaceFileFactory;
 import org.apache.hyracks.api.job.JobId;
@@ -26,15 +26,15 @@ import org.apache.hyracks.api.job.profiling.counters.ICounterContext;
 import org.apache.hyracks.api.resources.IDeallocatableRegistry;
 
 public interface IHyracksJobletContext extends IWorkspaceFileFactory, IDeallocatableRegistry {
-    public INCApplicationContext getApplicationContext();
+    INCServiceContext getServiceContext();
 
-    public JobId getJobId();
+    JobId getJobId();
 
-    public ICounterContext getCounterContext();
+    ICounterContext getCounterContext();
 
-    public Object getGlobalJobData();
+    Object getGlobalJobData();
 
-    public Class<?> loadClass(String className) throws HyracksException;
+    Class<?> loadClass(String className) throws HyracksException;
 
-    public ClassLoader getClassLoader() throws HyracksException;
+    ClassLoader getClassLoader() throws HyracksException;
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IConnectorDescriptor.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IConnectorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IConnectorDescriptor.java
index abff2f7..36cd6a5 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IConnectorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IConnectorDescriptor.java
@@ -22,7 +22,7 @@ import java.io.Serializable;
 import java.util.BitSet;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import org.apache.hyracks.api.application.ICCApplicationContext;
+import org.apache.hyracks.api.application.ICCServiceContext;
 import org.apache.hyracks.api.comm.IFrameWriter;
 import org.apache.hyracks.api.comm.IPartitionCollector;
 import org.apache.hyracks.api.comm.IPartitionWriterFactory;
@@ -98,7 +98,7 @@ public interface IConnectorDescriptor extends Serializable {
      *            - Activity Cluster
      */
     public void contributeSchedulingConstraints(IConstraintAcceptor constraintAcceptor, ActivityCluster ac,
-            ICCApplicationContext appCtx);
+            ICCServiceContext ccServiceCtx);
 
     /**
      * Indicate which consumer partitions may receive data from the given

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IOperatorDescriptor.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IOperatorDescriptor.java
index b02c4f2..9148d6b 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/IOperatorDescriptor.java
@@ -22,7 +22,7 @@ import java.io.Serializable;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.hyracks.api.application.ICCApplicationContext;
+import org.apache.hyracks.api.application.ICCServiceContext;
 import org.apache.hyracks.api.constraints.IConstraintAcceptor;
 import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
 
@@ -84,7 +84,7 @@ public interface IOperatorDescriptor extends Serializable {
      * @param plan
      *            - Job Plan
      */
-    public void contributeSchedulingConstraints(IConstraintAcceptor constraintAcceptor, ICCApplicationContext appCtx);
+    public void contributeSchedulingConstraints(IConstraintAcceptor constraintAcceptor, ICCServiceContext ccServiceCtx);
 
     /**
      * Gets the display name.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/job/IActivityClusterGraphGeneratorFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/job/IActivityClusterGraphGeneratorFactory.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/job/IActivityClusterGraphGeneratorFactory.java
index 7d02155..133e342 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/job/IActivityClusterGraphGeneratorFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/job/IActivityClusterGraphGeneratorFactory.java
@@ -19,14 +19,14 @@
 package org.apache.hyracks.api.job;
 
 import java.io.Serializable;
-import java.util.EnumSet;
+import java.util.Set;
 
-import org.apache.hyracks.api.application.ICCApplicationContext;
+import org.apache.hyracks.api.application.ICCServiceContext;
 import org.apache.hyracks.api.exceptions.HyracksException;
 
 public interface IActivityClusterGraphGeneratorFactory extends Serializable {
     public IActivityClusterGraphGenerator createActivityClusterGraphGenerator(JobId jobId,
-            ICCApplicationContext ccAppCtx, EnumSet<JobFlag> jobFlags) throws HyracksException;
+            ICCServiceContext ccServiceCtx, Set<JobFlag> jobFlags) throws HyracksException;
 
     public JobSpecification getJobSpecification();
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/service/IControllerService.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/service/IControllerService.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/service/IControllerService.java
index 2e742ac..aecc643 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/service/IControllerService.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/service/IControllerService.java
@@ -18,8 +18,14 @@
  */
 package org.apache.hyracks.api.service;
 
+import org.apache.hyracks.api.application.IServiceContext;
+
 public interface IControllerService {
-    public void start() throws Exception;
+    void start() throws Exception;
+
+    void stop() throws Exception;
+
+    IServiceContext getContext();
 
-    public void stop() throws Exception;
+    Object getApplicationContext();
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
new file mode 100644
index 0000000..ccdd493
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/BaseCCApplication.java
@@ -0,0 +1,79 @@
+/*
+ * 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.hyracks.control.cc;
+
+import java.util.Arrays;
+
+import org.apache.hyracks.api.application.ICCApplication;
+import org.apache.hyracks.api.application.IServiceContext;
+import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.api.config.IConfigManager;
+import org.apache.hyracks.api.config.Section;
+import org.apache.hyracks.api.job.resource.DefaultJobCapacityController;
+import org.apache.hyracks.api.job.resource.IJobCapacityController;
+import org.apache.hyracks.control.common.controllers.CCConfig;
+import org.apache.hyracks.control.common.controllers.ControllerConfig;
+import org.apache.hyracks.control.common.controllers.NCConfig;
+
+public class BaseCCApplication implements ICCApplication {
+    public static final ICCApplication INSTANCE = new BaseCCApplication();
+
+    protected BaseCCApplication() {
+    }
+
+    @Override
+    public void start(IServiceContext serviceCtx, String[] args) throws Exception {
+        if (args.length > 0) {
+            throw new IllegalArgumentException("Unrecognized argument(s): " + Arrays.toString(args));
+        }
+    }
+
+    @Override
+    public void stop() throws Exception {
+        // no-op
+    }
+
+    @Override
+    public void startupCompleted() throws Exception {
+        // no-op
+    }
+
+    @Override
+    public IJobCapacityController getJobCapacityController() {
+        return DefaultJobCapacityController.INSTANCE;
+    }
+
+    @Override
+    public void registerConfig(IConfigManager configManager) {
+        configManager.addIniParamOptions(ControllerConfig.Option.CONFIG_FILE, ControllerConfig.Option.CONFIG_FILE_URL);
+        configManager.addCmdLineSections(Section.CC, Section.COMMON);
+        configManager.setUsageFilter(getUsageFilter());
+        configManager.register(ControllerConfig.Option.class, CCConfig.Option.class, NCConfig.Option.class);
+    }
+
+    @Override
+    public Object getApplicationContext() {
+        return null;
+    }
+
+    @Override
+    public IHyracksClientConnection getHcc() throws Exception {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCApplicationEntryPoint.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCApplicationEntryPoint.java
deleted file mode 100644
index 07008df..0000000
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCApplicationEntryPoint.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.control.cc;
-
-import java.util.Arrays;
-
-import org.apache.hyracks.api.application.ICCApplicationContext;
-import org.apache.hyracks.api.application.ICCApplicationEntryPoint;
-import org.apache.hyracks.api.config.IConfigManager;
-import org.apache.hyracks.api.config.Section;
-import org.apache.hyracks.api.job.resource.DefaultJobCapacityController;
-import org.apache.hyracks.api.job.resource.IJobCapacityController;
-import org.apache.hyracks.control.common.controllers.CCConfig;
-import org.apache.hyracks.control.common.controllers.ControllerConfig;
-import org.apache.hyracks.control.common.controllers.NCConfig;
-
-public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
-    public static final ICCApplicationEntryPoint INSTANCE = new CCApplicationEntryPoint();
-
-    protected CCApplicationEntryPoint() {
-    }
-
-    @Override
-    public void start(ICCApplicationContext ccAppCtx, String[] args) throws Exception {
-        if (args.length > 0) {
-            throw new IllegalArgumentException("Unrecognized argument(s): " + Arrays.toString(args));
-        }
-    }
-
-    @Override
-    public void stop() throws Exception {
-        // no-op
-    }
-
-    @Override
-    public void startupCompleted() throws Exception {
-        // no-op
-    }
-
-    @Override
-    public IJobCapacityController getJobCapacityController() {
-        return DefaultJobCapacityController.INSTANCE;
-    }
-
-    @Override
-    public void registerConfig(IConfigManager configManager) {
-        configManager.addIniParamOptions(ControllerConfig.Option.CONFIG_FILE, ControllerConfig.Option.CONFIG_FILE_URL);
-        configManager.addCmdLineSections(Section.CC, Section.COMMON);
-        configManager.setUsageFilter(getUsageFilter());
-        configManager.register(ControllerConfig.Option.class, CCConfig.Option.class, NCConfig.Option.class);
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
index 754deac..a78f6bb 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCDriver.java
@@ -25,7 +25,7 @@ import java.util.Arrays;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.hyracks.api.application.ICCApplicationEntryPoint;
+import org.apache.hyracks.api.application.ICCApplication;
 import org.apache.hyracks.control.common.config.ConfigManager;
 import org.apache.hyracks.control.common.config.ConfigUtils;
 import org.apache.hyracks.control.common.controllers.CCConfig;
@@ -40,10 +40,10 @@ public class CCDriver {
     public static void main(String[] args) throws Exception {
         try {
             final ConfigManager configManager = new ConfigManager(args);
-            ICCApplicationEntryPoint appEntryPoint = getAppEntryPoint(args);
-            appEntryPoint.registerConfig(configManager);
+            ICCApplication application = getApplication(args);
+            application.registerConfig(configManager);
             CCConfig ccConfig = new CCConfig(configManager);
-            ClusterControllerService ccService = new ClusterControllerService(ccConfig, appEntryPoint);
+            ClusterControllerService ccService = new ClusterControllerService(ccConfig, application);
             ccService.start();
             while (true) {
                 Thread.sleep(100000);
@@ -52,16 +52,16 @@ public class CCDriver {
             LOGGER.log(Level.FINE, "Exception parsing command line: " + Arrays.toString(args), e);
             System.exit(2);
         } catch (Exception e) {
-            LOGGER.log(Level.SEVERE, "Exiting NCDriver due to exception", e);
+            LOGGER.log(Level.SEVERE, "Exiting CCDriver due to exception", e);
             System.exit(1);
         }
     }
 
-    private static ICCApplicationEntryPoint getAppEntryPoint(String[] args)
+    private static ICCApplication getApplication(String[] args)
             throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
         // determine app class so that we can use the correct implementation of the configuration...
         String appClassName = ConfigUtils.getOptionValue(args, APP_CLASS);
-        return appClassName != null ? (ICCApplicationEntryPoint) (Class.forName(appClassName)).newInstance()
-                : CCApplicationEntryPoint.INSTANCE;
+        return appClassName != null ? (ICCApplication) (Class.forName(appClassName)).newInstance()
+                : BaseCCApplication.INSTANCE;
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
index 77404b5..5abc2e0 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
@@ -41,7 +41,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.hyracks.api.application.ICCApplicationEntryPoint;
+import org.apache.hyracks.api.application.ICCApplication;
 import org.apache.hyracks.api.client.ClusterControllerInfo;
 import org.apache.hyracks.api.comm.NetworkAddress;
 import org.apache.hyracks.api.config.IApplicationConfig;
@@ -53,7 +53,7 @@ import org.apache.hyracks.api.job.resource.IJobCapacityController;
 import org.apache.hyracks.api.service.IControllerService;
 import org.apache.hyracks.api.topology.ClusterTopology;
 import org.apache.hyracks.api.topology.TopologyDefinitionParser;
-import org.apache.hyracks.control.cc.application.CCApplicationContext;
+import org.apache.hyracks.control.cc.application.CCServiceContext;
 import org.apache.hyracks.control.cc.cluster.INodeManager;
 import org.apache.hyracks.control.cc.cluster.NodeManager;
 import org.apache.hyracks.control.cc.dataset.DatasetDirectoryService;
@@ -102,7 +102,7 @@ public class ClusterControllerService implements IControllerService {
 
     private ClusterControllerInfo info;
 
-    private CCApplicationContext appCtx;
+    private CCServiceContext serviceCtx;
 
     private final PreDistributedJobStore preDistributedJobStore = new PreDistributedJobStore();
 
@@ -132,20 +132,19 @@ public class ClusterControllerService implements IControllerService {
 
     private ShutdownRun shutdownCallback;
 
-    private final ICCApplicationEntryPoint aep;
+    private final ICCApplication application;
 
     public ClusterControllerService(final CCConfig config) throws Exception {
-        this(config, getApplicationEntryPoint(config));
+        this(config, getApplication(config));
     }
 
-    public ClusterControllerService(final CCConfig config,
-                                    final ICCApplicationEntryPoint aep) throws Exception {
+    public ClusterControllerService(final CCConfig config, final ICCApplication application) throws Exception {
         this.ccConfig = config;
         this.configManager = ccConfig.getConfigManager();
-        if (aep == null) {
-            throw new IllegalArgumentException("ICCApplicationEntryPoint cannot be null");
+        if (application == null) {
+            throw new IllegalArgumentException("ICCApplication cannot be null");
         }
-        this.aep = aep;
+        this.application = application;
         configManager.processConfig();
         File jobLogFolder = new File(ccConfig.getRootDir(), "logs/jobs");
         jobLog = new LogFile(jobLogFolder);
@@ -209,11 +208,11 @@ public class ClusterControllerService implements IControllerService {
     }
 
     private void startApplication() throws Exception {
-        appCtx = new CCApplicationContext(this, serverCtx, ccContext, ccConfig.getAppConfig());
-        appCtx.addJobLifecycleListener(datasetDirectoryService);
-        executor = Executors.newCachedThreadPool(appCtx.getThreadFactory());
-        aep.start(appCtx, ccConfig.getAppArgsArray());
-        IJobCapacityController jobCapacityController = aep.getJobCapacityController();
+        serviceCtx = new CCServiceContext(this, serverCtx, ccContext, ccConfig.getAppConfig());
+        serviceCtx.addJobLifecycleListener(datasetDirectoryService);
+        executor = Executors.newCachedThreadPool(serviceCtx.getThreadFactory());
+        application.start(serviceCtx, ccConfig.getAppArgsArray());
+        IJobCapacityController jobCapacityController = application.getJobCapacityController();
 
         // Job manager is in charge of job lifecycle management.
         try {
@@ -265,7 +264,7 @@ public class ClusterControllerService implements IControllerService {
     }
 
     private void notifyApplication() throws Exception {
-        aep.startupCompleted();
+        application.startupCompleted();
     }
 
     public void stop(boolean terminateNCService) throws Exception {
@@ -290,7 +289,7 @@ public class ClusterControllerService implements IControllerService {
     }
 
     private void stopApplication() throws Exception {
-        aep.stop();
+        application.stop();
     }
 
     public ServerContext getServerContext() {
@@ -337,8 +336,9 @@ public class ClusterControllerService implements IControllerService {
         return ccConfig;
     }
 
-    public CCApplicationContext getApplicationContext() {
-        return appCtx;
+    @Override
+    public CCServiceContext getContext() {
+        return serviceCtx;
     }
 
     public ClusterControllerInfo getClusterControllerInfo() {
@@ -454,17 +454,22 @@ public class ClusterControllerService implements IControllerService {
         return threadDumpRunMap.remove(requestKey);
     }
 
-    private static ICCApplicationEntryPoint getApplicationEntryPoint(CCConfig ccConfig)
+    private static ICCApplication getApplication(CCConfig ccConfig)
             throws ClassNotFoundException, IllegalAccessException, InstantiationException {
         if (ccConfig.getAppClass() != null) {
             Class<?> c = Class.forName(ccConfig.getAppClass());
-            return (ICCApplicationEntryPoint) c.newInstance();
+            return (ICCApplication) c.newInstance();
         } else {
-            return CCApplicationEntryPoint.INSTANCE;
+            return BaseCCApplication.INSTANCE;
         }
     }
 
-    public ICCApplicationEntryPoint getApplication() {
-        return aep;
+    public ICCApplication getApplication() {
+        return application;
+    }
+
+    @Override
+    public Object getApplicationContext() {
+        return application.getApplicationContext();
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/953eb966/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
deleted file mode 100644
index a8b03bc..0000000
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/application/CCApplicationContext.java
+++ /dev/null
@@ -1,125 +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.hyracks.control.cc.application;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.hyracks.api.application.ICCApplicationContext;
-import org.apache.hyracks.api.application.IClusterLifecycleListener;
-import org.apache.hyracks.api.config.IApplicationConfig;
-import org.apache.hyracks.api.config.IOption;
-import org.apache.hyracks.api.context.ICCContext;
-import org.apache.hyracks.api.exceptions.HyracksException;
-import org.apache.hyracks.api.job.IJobLifecycleListener;
-import org.apache.hyracks.api.job.JobId;
-import org.apache.hyracks.api.job.JobSpecification;
-import org.apache.hyracks.api.service.IControllerService;
-import org.apache.hyracks.control.cc.ClusterControllerService;
-import org.apache.hyracks.control.common.application.ApplicationContext;
-import org.apache.hyracks.control.common.context.ServerContext;
-import org.apache.hyracks.control.common.utils.HyracksThreadFactory;
-import org.apache.hyracks.control.common.work.IResultCallback;
-
-public class CCApplicationContext extends ApplicationContext implements ICCApplicationContext {
-    private final ICCContext ccContext;
-
-    protected final Set<String> initPendingNodeIds;
-    protected final Set<String> deinitPendingNodeIds;
-
-    protected IResultCallback<Object> initializationCallback;
-    protected IResultCallback<Object> deinitializationCallback;
-
-    private List<IJobLifecycleListener> jobLifecycleListeners;
-    private List<IClusterLifecycleListener> clusterLifecycleListeners;
-    private final ClusterControllerService ccs;
-
-    public CCApplicationContext(ClusterControllerService ccs, ServerContext serverCtx, ICCContext ccContext,
-            IApplicationConfig appConfig) throws IOException {
-        super(serverCtx, appConfig, new HyracksThreadFactory("ClusterController"));
-        this.ccContext = ccContext;
-        this.ccs = ccs;
-        initPendingNodeIds = new HashSet<>();
-        deinitPendingNodeIds = new HashSet<>();
-        jobLifecycleListeners = new ArrayList<>();
-        clusterLifecycleListeners = new ArrayList<>();
-    }
-
-    @Override
-    public ICCContext getCCContext() {
-        return ccContext;
-    }
-
-    @Override
-    public void setDistributedState(Serializable state) {
-        this.distributedState = state;
-    }
-
-    @Override
-    public void addJobLifecycleListener(IJobLifecycleListener jobLifecycleListener) {
-        jobLifecycleListeners.add(jobLifecycleListener);
-    }
-
-    public synchronized void notifyJobStart(JobId jobId) throws HyracksException {
-        for (IJobLifecycleListener l : jobLifecycleListeners) {
-            l.notifyJobStart(jobId);
-        }
-    }
-
-    public synchronized void notifyJobFinish(JobId jobId) throws HyracksException {
-        for (IJobLifecycleListener l : jobLifecycleListeners) {
-            l.notifyJobFinish(jobId);
-        }
-    }
-
-    public synchronized void notifyJobCreation(JobId jobId, JobSpecification spec)
-            throws HyracksException {
-        for (IJobLifecycleListener l : jobLifecycleListeners) {
-            l.notifyJobCreation(jobId, spec);
-        }
-    }
-
-    @Override
-    public void addClusterLifecycleListener(IClusterLifecycleListener clusterLifecycleListener) {
-        clusterLifecycleListeners.add(clusterLifecycleListener);
-    }
-
-    public void notifyNodeJoin(String nodeId, Map<IOption, Object> ncConfiguration) throws HyracksException {
-        for (IClusterLifecycleListener l : clusterLifecycleListeners) {
-            l.notifyNodeJoin(nodeId, ncConfiguration);
-        }
-    }
-
-    public void notifyNodeFailure(Collection<String> deadNodeIds) throws HyracksException {
-        for (IClusterLifecycleListener l : clusterLifecycleListeners) {
-            l.notifyNodeFailure(deadNodeIds);
-        }
-    }
-
-    @Override
-    public IControllerService getControllerService() {
-        return ccs;
-    }
-}


Mime
View raw message