myriad-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smare...@apache.org
Subject [8/8] incubator-myriad git commit: Minor changes for destroy Myriad to work smoothly
Date Wed, 28 Oct 2015 23:49:27 GMT
Minor changes for destroy Myriad to work smoothly

* Making MyriadWebServer singleton
* Stopping the webserver after the driver has shutdown so there can be no more flexup and
flexdown requests
* Making sure that the Myriad UI works on older versions of Firefox and IE.
  Minor syntax changes in js files like
-       renderOverlay() {
+       renderOverlay: function () {

This closes: #21
Review: #21


Project: http://git-wip-us.apache.org/repos/asf/incubator-myriad/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-myriad/commit/2df7da0e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-myriad/tree/2df7da0e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-myriad/diff/2df7da0e

Branch: refs/heads/master
Commit: 2df7da0e14825f183e3c8770b4a42715e46ad56a
Parents: e637513
Author: Swapnil Daingade <sdaingade@maprtech.com>
Authored: Mon Oct 26 13:21:28 2015 -0700
Committer: Santosh Marella <marella@gmail.com>
Committed: Wed Oct 28 14:20:33 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/myriad/MyriadModule.java    |    2 +
 .../apache/myriad/api/ControllerResource.java   |   56 +-
 .../myriad/scheduler/MyriadOperations.java      |   14 +-
 .../apache/myriad/webapp/MyriadWebServer.java   |    5 +-
 .../src/main/resources/webapp/js/app.js         |    2 +-
 .../js/components/ShutdownFrameworkComponent.js |   12 +-
 .../main/resources/webapp/public/js/myriad.js   | 7613 +++++-------------
 7 files changed, 2192 insertions(+), 5512 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/2df7da0e/myriad-scheduler/src/main/java/org/apache/myriad/MyriadModule.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/org/apache/myriad/MyriadModule.java b/myriad-scheduler/src/main/java/org/apache/myriad/MyriadModule.java
index 659160e..59866fe 100644
--- a/myriad-scheduler/src/main/java/org/apache/myriad/MyriadModule.java
+++ b/myriad-scheduler/src/main/java/org/apache/myriad/MyriadModule.java
@@ -52,6 +52,7 @@ import com.google.inject.multibindings.MapBinder;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.AbstractYarnScheduler;
+import org.apache.myriad.webapp.MyriadWebServer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -91,6 +92,7 @@ public class MyriadModule extends AbstractModule {
     bind(DisruptorManager.class).in(Scopes.SINGLETON);
     bind(ReconcileService.class).in(Scopes.SINGLETON);
     bind(HttpConnectorProvider.class).in(Scopes.SINGLETON);
+    bind(MyriadWebServer.class).in(Scopes.SINGLETON);
     bind(TaskConstraintsManager.class).in(Scopes.SINGLETON);
     // add special binding between TaskFactory and NMTaskFactoryImpl to ease up
     // usage of TaskFactory

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/2df7da0e/myriad-scheduler/src/main/java/org/apache/myriad/api/ControllerResource.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/org/apache/myriad/api/ControllerResource.java
b/myriad-scheduler/src/main/java/org/apache/myriad/api/ControllerResource.java
index b47f1cc..7ab5a59 100644
--- a/myriad-scheduler/src/main/java/org/apache/myriad/api/ControllerResource.java
+++ b/myriad-scheduler/src/main/java/org/apache/myriad/api/ControllerResource.java
@@ -19,46 +19,44 @@
 package org.apache.myriad.api;
 
 import com.codahale.metrics.annotation.Timed;
-import org.apache.myriad.scheduler.MyriadOperations;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import javax.inject.Inject;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import org.apache.myriad.scheduler.MyriadOperations;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * RESTful API to resource manager
  */
 @Path("/framework")
 public class ControllerResource {
-    private static final Logger LOGGER = LoggerFactory.getLogger(ControllerResource.class);
+  private static final Logger LOGGER = LoggerFactory.getLogger(ControllerResource.class);
+
+  private MyriadOperations myriadOperations;
+
+  @Inject
+  public ControllerResource(MyriadOperations myriadOperations) {
+    this.myriadOperations = myriadOperations;
+  }
+
+  /**
+   * Shutdown framework means the Mesos driver is stopped, all executors and tasks as well.
+   *
+   * @return a successful response.
+   */
+  @Timed
+  @GET
+  @Path("/shutdown/framework")
+  @Produces(MediaType.APPLICATION_JSON)
+  public Response shutdownFramework() {
+    LOGGER.info("shutdown....terminating framework... ");
+
+    myriadOperations.shutdownFramework();
 
-    private MyriadOperations myriadOperations;
-    
-    @Inject
-    public ControllerResource(MyriadOperations myriadOperations) {
-        this.myriadOperations = myriadOperations;
-    }
-    /**
-     * Shutdown framework means the Mesos driver is stopped, all executors and tasks as well.
-      * 
-     * @return a successful response. 
-     */      
-    @Timed
-    @GET
-    @Path("/shutdown/framework")
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response shutdownFramework() {
-        LOGGER.info("shutdown....terminating framework... ");
-         
-        myriadOperations.shutdownFramework();
-        
-        return Response.ok().build();
-    }  
-    
-   
+    return Response.ok().build();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/2df7da0e/myriad-scheduler/src/main/java/org/apache/myriad/scheduler/MyriadOperations.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/org/apache/myriad/scheduler/MyriadOperations.java
b/myriad-scheduler/src/main/java/org/apache/myriad/scheduler/MyriadOperations.java
index 11d1c82..a6449b1 100644
--- a/myriad-scheduler/src/main/java/org/apache/myriad/scheduler/MyriadOperations.java
+++ b/myriad-scheduler/src/main/java/org/apache/myriad/scheduler/MyriadOperations.java
@@ -32,6 +32,7 @@ import com.google.common.collect.Lists;
 import com.google.inject.Inject;
 
 import org.apache.mesos.Protos;
+import org.apache.myriad.webapp.MyriadWebServer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,13 +51,15 @@ public class MyriadOperations {
   private MyriadConfiguration cfg;
   private NodeScaleDownPolicy nodeScaleDownPolicy;
   private MyriadDriverManager driverManager;
+  private MyriadWebServer myriadWebServer;
 
   @Inject
-  public MyriadOperations(MyriadConfiguration cfg, SchedulerState schedulerState, NodeScaleDownPolicy
nodeScaleDownPolicy, MyriadDriverManager driverManager) {
+  public MyriadOperations(MyriadConfiguration cfg, SchedulerState schedulerState, NodeScaleDownPolicy
nodeScaleDownPolicy, MyriadDriverManager driverManager, MyriadWebServer myriadWebServer) {
     this.cfg = cfg;
     this.schedulerState = schedulerState;
     this.nodeScaleDownPolicy = nodeScaleDownPolicy;
     this.driverManager = driverManager;
+    this.myriadWebServer = myriadWebServer;
   }
 
   public void flexUpCluster(ServiceResourceProfile serviceResourceProfile, int instances,
Constraint constraint) {
@@ -247,7 +250,14 @@ public class MyriadOperations {
     } else {
       // Stop the driver, tasks, and executor.
       driverStatus = driverManager.stopDriver(false);
-      LOGGER.info("shutdown....driver status " + driverStatus);
+      LOGGER.info("Myriad driver was shutdown with status " + driverStatus);
+      try {
+        myriadWebServer.stop();
+      } catch (Exception e) {
+        LOGGER.info("Failed to shutdown Myriad webserver: " + e.getMessage());
+        return;
+      }
+      LOGGER.info("Myriad webserver was shutdown successfully");
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/2df7da0e/myriad-scheduler/src/main/java/org/apache/myriad/webapp/MyriadWebServer.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/java/org/apache/myriad/webapp/MyriadWebServer.java
b/myriad-scheduler/src/main/java/org/apache/myriad/webapp/MyriadWebServer.java
index ac36683..98edfba 100644
--- a/myriad-scheduler/src/main/java/org/apache/myriad/webapp/MyriadWebServer.java
+++ b/myriad-scheduler/src/main/java/org/apache/myriad/webapp/MyriadWebServer.java
@@ -68,5 +68,8 @@ public class MyriadWebServer {
     this.jetty.start();
   }
 
-
+  public void stop() throws Exception {
+    this.jetty.stop();
+    this.connector.close();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/2df7da0e/myriad-scheduler/src/main/resources/webapp/js/app.js
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/resources/webapp/js/app.js b/myriad-scheduler/src/main/resources/webapp/js/app.js
index 44a00b9..4723f65 100644
--- a/myriad-scheduler/src/main/resources/webapp/js/app.js
+++ b/myriad-scheduler/src/main/resources/webapp/js/app.js
@@ -14,7 +14,7 @@ var Router = require('react-router')
 
 var routes = (
   <Route name="myriad" path="/" handler={Myriad} >
-    <Route name="frameworkDown" path="frameworkDown" {...this.props} handler={ShutdownFrameworkComponent}
/> 
+    <Route name="frameworkDown" path="frameworkDown" {...this.props} handler={ShutdownFrameworkComponent}
/>
     <Route name="flex" path="flex" handler={FlexComponent} />
     <Route name="tasks" path="tasks" handler={TasksComponent} />
     <Route name="help" path="help" handler={HelpComponent} />

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/2df7da0e/myriad-scheduler/src/main/resources/webapp/js/components/ShutdownFrameworkComponent.js
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/main/resources/webapp/js/components/ShutdownFrameworkComponent.js
b/myriad-scheduler/src/main/resources/webapp/js/components/ShutdownFrameworkComponent.js
index 27a515b..5fc7e0d 100644
--- a/myriad-scheduler/src/main/resources/webapp/js/components/ShutdownFrameworkComponent.js
+++ b/myriad-scheduler/src/main/resources/webapp/js/components/ShutdownFrameworkComponent.js
@@ -10,13 +10,13 @@ var request = require('superagent');
 var XModal = React.createClass({
   	mixins: [OverlayMixin],
 
-  	getInitialState() {
+  	getInitialState: function () {
     		return {
       			isModalOpen: false
     		};
   	},
 
-  	handleToggle() {
+  	handleToggle: function () {
 		// For whatever reason this toggle does not work as claimed on line....so cheat.
 		if (!this.state.isModalOpen)
     	    		document.getElementById('shutdownModal').style.visibility = "hidden";
@@ -24,7 +24,7 @@ var XModal = React.createClass({
             		isModalOpen: !this.state.isModalOpen
         	});
   	},
-  	render() {
+  	render: function () {
     		return ( <Modal {...this.props} bsStyle='primary'   id="shutdownModal" title='Shutdown
Myriad Framework ?' animation={false}  					onRequestHide={this.handleToggle}>
 	 			<div className='modal-body' >
 					<p> This will stop the driver in failover mode, which will stop the executor and
tasks, but not stop the ResourceManager.</p>
@@ -42,7 +42,7 @@ var XModal = React.createClass({
      			</Modal>);
   	},
 
- 	renderOverlay() {
+ 	renderOverlay: function () {
       	   		return <span/>;
   	}
 });
@@ -52,12 +52,12 @@ var ShutdownFrameworkComponent = React.createClass({
 
   	displayName: "ShutdownFrameworkComponent",
 
-  	render() {
+  	render: function() {
    		return (
   			<XModal onShutdown={this.onRequestShutdown} onCancel={this.onCancel}/>
     		);
   	},
- 	onCancel : function() {
+ 	onCancel: function() {
         	this.transitionTo("tasks");
 	},
   	onRequestShutdown: function() {


Mime
View raw message