added managix commands for starting/stopping a node
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartNodeCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartNodeCommand.java
new file mode 100644
index 0000000..6daf4fc
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartNodeCommand.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.installer.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.error.VerificationUtil;
+import edu.uci.ics.asterix.event.management.AsterixEventServiceClient;
+import edu.uci.ics.asterix.event.model.AsterixInstance;
+import edu.uci.ics.asterix.event.model.AsterixInstance.State;
+import edu.uci.ics.asterix.event.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.event.service.AsterixEventService;
+import edu.uci.ics.asterix.event.service.AsterixEventServiceUtil;
+import edu.uci.ics.asterix.event.service.ServiceProvider;
+import edu.uci.ics.asterix.event.util.PatternCreator;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+
+public class StartNodeCommand extends AbstractCommand {
+
+    @Override
+    protected void execCommand() throws Exception {
+        InstallerDriver.initConfig(true);
+        String asterixInstanceName = ((StartNodeConfig) config).name;
+        AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName,
+                State.INACTIVE, State.ACTIVE, State.UNUSABLE);
+
+        Cluster cluster = instance.getCluster();
+        List<Pattern> pl = new ArrayList<Pattern>();
+        String[] nodesToBeAdded = ((StartNodeConfig) config).nodes.split(",");
+        List<Node> clusterNodes = cluster.getNode();
+        for (String n : nodesToBeAdded) {
+            for (Node node : clusterNodes) {
+                if (n.equals(node.getId())) {
+                    String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+                    Pattern createNC = PatternCreator.INSTANCE.createNCStartPattern(cluster.getMasterNode()
+                            .getClusterIp(), node.getId(), asterixInstanceName + "_" + node.getId(), iodevices);
+                    pl.add(createNC);
+                    break;
+                }
+            }
+        }
+        Patterns patterns = new Patterns(pl);
+        AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(cluster);
+        client.submit(patterns);
+        AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(instance);
+        VerificationUtil.updateInstanceWithRuntimeDescription(instance, runtimeState, true);
+        LOGGER.info(instance.getDescription(false));
+        ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+    }
+
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new StartNodeConfig();
+    }
+
+    @Override
+    protected String getUsageDescription() {
+        return "\nStarts a set of nodes for an ASTERIX instance." + "\n\nAvailable arguments/options"
+                + "\n-n name of the ASTERIX instance. " + "\n-nodes"
+                + "Comma separated list of nodes that need to be started";
+    }
+}
+
+class StartNodeConfig extends CommandConfig {
+
+    @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+    public String name;
+
+    @Option(name = "-nodes", required = true, usage = "Comma separated list of nodes that need to be started")
+    public String nodes;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopNodeCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopNodeCommand.java
new file mode 100644
index 0000000..a0dc7c5
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopNodeCommand.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.installer.command;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.management.AsterixEventServiceClient;
+import edu.uci.ics.asterix.event.model.AsterixInstance;
+import edu.uci.ics.asterix.event.model.AsterixInstance.State;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.pattern.Pattern;
+import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.event.service.AsterixEventService;
+import edu.uci.ics.asterix.event.service.AsterixEventServiceUtil;
+import edu.uci.ics.asterix.event.service.ServiceProvider;
+import edu.uci.ics.asterix.event.util.PatternCreator;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.error.InstallerException;
+
+public class StopNodeCommand extends AbstractCommand {
+
+    @Override
+    protected void execCommand() throws Exception {
+        InstallerDriver.initConfig(true);
+        String asterixInstanceName = ((StopNodeConfig) config).name;
+        AsterixInstance asterixInstance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName,
+                State.ACTIVE, State.UNUSABLE);
+
+        AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(asterixInstance
+                .getCluster());
+
+        String[] nodesToStop = ((StopNodeConfig) config).nodeList.split(",");
+        List<String> validNodeIds = new ArrayList<String>();
+        for (Node node : asterixInstance.getCluster().getNode()) {
+            validNodeIds.add(node.getId());
+        }
+        List<Pattern> ncKillPatterns = new ArrayList<Pattern>();
+        for (String nodeId : nodesToStop) {
+            if (!nodeId.contains(nodeId)) {
+                throw new InstallerException("Invalid nodeId: " + nodeId);
+            }
+            ncKillPatterns.add(PatternCreator.INSTANCE.createNCStopPattern(nodeId, asterixInstanceName + "_" + nodeId));
+        }
+
+        try {
+            client.submit(new Patterns(ncKillPatterns));
+        } catch (Exception e) {
+            // processes are already dead
+            LOGGER.debug("Attempt to kill non-existing processess");
+        }
+
+        asterixInstance.setStateChangeTimestamp(new Date());
+        ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance);
+        LOGGER.info("Stopped nodes " + ((StopNodeConfig) config).nodeList + " serving Asterix instance: "
+                + asterixInstanceName);
+    }
+
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new StopNodeConfig();
+    }
+
+    @Override
+    protected String getUsageDescription() {
+        return "\nStops a specified set of ASTERIX nodes." + "\n\nAvailable arguments/options"
+                + "\n-n name of the ASTERIX instance. "
+                + "\n-nodes Comma separated list of nodes that need to be stopped. ";
+
+    }
+}
+
+class StopNodeConfig extends CommandConfig {
+
+    @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+    public String name;
+
+    @Option(name = "-nodes", required = true, usage = "Comma separated list of nodes that need to be stopped")
+    public String nodeList;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/VersionCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/VersionCommand.java
new file mode 100644
index 0000000..50e13ac
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/VersionCommand.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+
+import edu.uci.ics.asterix.event.service.AsterixEventService;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+
+public class VersionCommand extends AbstractCommand {
+
+    @Override
+    protected void execCommand() throws Exception {
+        InstallerDriver.initConfig(true);
+        String asterixZipName = AsterixEventService.getAsterixZip().substring(
+                AsterixEventService.getAsterixZip().lastIndexOf(File.separator) + 1);
+        String asterixVersion = asterixZipName.substring("asterix-server-".length(),
+                asterixZipName.indexOf("-binary-assembly"));
+        LOGGER.info("Asterix/Managix version " + asterixVersion);
+    }
+
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new VersionConfig();
+    }
+
+    @Override
+    protected String getUsageDescription() {
+        return "Provides version of Managix/Asterix";
+    }
+
+}
+
+class VersionConfig extends CommandConfig {
+
+}
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixFaultToleranceIT.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixFaultToleranceIT.java
new file mode 100644
index 0000000..34fa915
--- /dev/null
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixFaultToleranceIT.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2009-2013 by The Regents of the University of California
+ * Licensed 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 from
+ * 
+ *     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 edu.uci.ics.asterix.installer.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameters;
+
+import edu.uci.ics.asterix.test.aql.TestsUtils;
+import edu.uci.ics.asterix.testframework.context.TestCaseContext;
+
+public class AsterixFaultToleranceIT {
+
+    private static final String PATH_BASE = "src/test/resources/integrationts/fault-tolerance";
+    private static final String PATH_ACTUAL = "ittest/";
+    private static final Logger LOGGER = Logger.getLogger(AsterixFaultToleranceIT.class.getName());
+    private static List<TestCaseContext> testCaseCollection;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        AsterixInstallerIntegrationUtil.init();
+        TestCaseContext.Builder b = new TestCaseContext.Builder();
+        testCaseCollection = b.build(new File(PATH_BASE));
+        File outdir = new File(PATH_ACTUAL);
+        outdir.mkdirs();
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        AsterixInstallerIntegrationUtil.deinit();
+        File outdir = new File(PATH_ACTUAL);
+        File[] files = outdir.listFiles();
+        if (files == null || files.length == 0) {
+            outdir.delete();
+        }
+    }
+
+    @Parameters
+    public static Collection<Object[]> tests() throws Exception {
+        Collection<Object[]> testArgs = new ArrayList<Object[]>();
+        return testArgs;
+    }
+
+    @Test
+    public void test() throws Exception {
+        for (TestCaseContext testCaseCtx : testCaseCollection) {
+            TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        try {
+            setUp();
+            new AsterixFaultToleranceIT().test();
+        } catch (Exception e) {
+            e.printStackTrace();
+            LOGGER.info("TEST CASE(S) FAILED");
+        } finally {
+            tearDown();
+        }
+    }
+
+}
diff --git a/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.1.ddl.aql b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.1.ddl.aql
new file mode 100644
index 0000000..b204892
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.1.ddl.aql
@@ -0,0 +1,29 @@
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends_count: int32,
+	statuses_count: int32,
+	name: string,
+	followers_count: int32
+} 
+
+create type TweetMessageType as closed {
+	tweetid: string,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	message-text: string
+}
+
+create nodegroup feedGroup on asterix_node1;
+
+create feed dataset TwitterFirehoseFeed(TweetMessageType)
+using twitter_firehose
+(("duration"="30"),("tps"="50"),("dataverse-dataset"="feeds:TwitterFirehoseFeed"))
+primary key tweetid on feedGroup;
+
diff --git a/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.2.update.aql b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.2.update.aql
new file mode 100644
index 0000000..382425f
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.2.update.aql
@@ -0,0 +1,4 @@
+use dataverse feeds;
+
+begin feed TwitterFirehoseFeed;
+
diff --git a/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.3.mgx.aql b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.3.mgx.aql
new file mode 100644
index 0000000..2724be9
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.3.mgx.aql
@@ -0,0 +1 @@
+stopnode -n asterix -nodes node1
diff --git a/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.4.query.aql b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.4.query.aql
new file mode 100644
index 0000000..474835a
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.4.query.aql
@@ -0,0 +1,4 @@
+use dataverse feeds;
+
+for $x in dataset Metadata.FeedActivity
+return $x
diff --git a/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.5.query.aql b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.5.query.aql
new file mode 100644
index 0000000..b173136
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/fault-tolerance/queries/feeds/IN2-1/in2-1.5.query.aql
@@ -0,0 +1,14 @@
+use dataverse feeds;
+
+let $c:=count(
+for $x in dataset TwitterFirehoseFeed
+return $x
+)
+
+let $result :=
+if ($c > 20000)
+then
+  true
+else 
+ false
+return $result
diff --git a/asterix-installer/src/test/resources/integrationts/fault-tolerance/testsuite.xml b/asterix-installer/src/test/resources/integrationts/fault-tolerance/testsuite.xml
new file mode 100644
index 0000000..859f29a
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/fault-tolerance/testsuite.xml
@@ -0,0 +1,10 @@
+<test-suite xmlns="urn:xml.testframework.asterix.ics.uci.edu" ResultOffsetPath="results" QueryOffsetPath="queries" QueryFileExtension=".aql">
+  <test-group name="fault-tolerance">
+    <test-case FilePath="feeds">
+      <compilation-unit name="IN2-1">
+        <output-dir compare="Text">IN2-1</output-dir>
+      </compilation-unit>
+    </test-case>
+  </test-group>
+</test-suite>
+