usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [27/50] [abbrv] git commit: Show chop coordinator logs on coordinator user interface
Date Fri, 13 Jun 2014 18:54:06 GMT
Show chop coordinator logs on coordinator user interface


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/22df31b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/22df31b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/22df31b0

Branch: refs/heads/two-dot-o
Commit: 22df31b0cd6d9dc049b02f8c257daa8574b41303
Parents: 250a3f9
Author: Furkan Bicak <bicak.cs@safehaus.org>
Authored: Thu Jun 12 16:18:14 2014 +0300
Committer: Furkan Bicak <bicak.cs@safehaus.org>
Committed: Thu Jun 12 16:18:14 2014 +0300

----------------------------------------------------------------------
 chop/check_style.xml                            |   2 +-
 .../apache/usergrid/chop/plugin/ResetMojo.java  |  27 +++--
 .../webapp/coordinator/rest/SetupResource.java  |  37 +++---
 .../chop/webapp/view/log/LogLayout.java         | 113 +++++++++++++++++++
 .../chop/webapp/view/main/MainView.java         |   7 ++
 5 files changed, 158 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/22df31b0/chop/check_style.xml
----------------------------------------------------------------------
diff --git a/chop/check_style.xml b/chop/check_style.xml
index 4f1cfc6..55a245c 100644
--- a/chop/check_style.xml
+++ b/chop/check_style.xml
@@ -67,4 +67,4 @@
       <property name="option" value="space"/>
     </module>
   </module>
-</module>
\ No newline at end of file
+</module>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/22df31b0/chop/plugin/src/main/java/org/apache/usergrid/chop/plugin/ResetMojo.java
----------------------------------------------------------------------
diff --git a/chop/plugin/src/main/java/org/apache/usergrid/chop/plugin/ResetMojo.java b/chop/plugin/src/main/java/org/apache/usergrid/chop/plugin/ResetMojo.java
index 36974aa..0ba2bc0 100644
--- a/chop/plugin/src/main/java/org/apache/usergrid/chop/plugin/ResetMojo.java
+++ b/chop/plugin/src/main/java/org/apache/usergrid/chop/plugin/ResetMojo.java
@@ -41,22 +41,25 @@ import com.sun.jersey.api.client.config.DefaultClientConfig;
 @Mojo( name = "reset" )
 public class ResetMojo extends MainMojo {
 
+
     public ResetMojo() {
 
     }
+
+
     protected ResetMojo( MainMojo mojo ) {
-            this.username = mojo.username;
-            this.password = mojo.password;
-            this.endpoint = mojo.endpoint;
-            this.testPackageBase = mojo.testPackageBase;
-            this.certStorePassphrase = mojo.certStorePassphrase;
-            this.failIfCommitNecessary = mojo.failIfCommitNecessary;
-            this.localRepository = mojo.localRepository;
-            this.plugin = mojo.plugin;
-            this.project = mojo.project;
-            this.runnerCount = mojo.runnerCount;
-            this.finalName = mojo.finalName;
-        }
+        this.username = mojo.username;
+        this.password = mojo.password;
+        this.endpoint = mojo.endpoint;
+        this.testPackageBase = mojo.testPackageBase;
+        this.certStorePassphrase = mojo.certStorePassphrase;
+        this.failIfCommitNecessary = mojo.failIfCommitNecessary;
+        this.localRepository = mojo.localRepository;
+        this.plugin = mojo.plugin;
+        this.project = mojo.project;
+        this.runnerCount = mojo.runnerCount;
+        this.finalName = mojo.finalName;
+    }
 
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/22df31b0/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/SetupResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/SetupResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/SetupResource.java
index 001d4dc..3a31c1f 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/SetupResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/SetupResource.java
@@ -120,24 +120,31 @@ public class SetupResource extends TestableResource implements RestParams
{
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
-        if( status.equals( SetupStackState.Destroying ) ) {
-            return Response.status( Response.Status.OK )
-                           .entity( SetupStackState.Destroying.getMessage() )
-                           .type( MediaType.APPLICATION_JSON )
-                           .build();
-        }
-        if( status.equals( SetupStackState.SettingUp ) ) {
-            return Response.status( Response.Status.OK )
-                           .entity( SetupStackState.SettingUp.getMessage() )
-                           .type( MediaType.APPLICATION_JSON )
-                           .build();
-        }
-        if( status.equals( SetupStackState.SetUp ) ) {
+
+        if( ! status.equals( SetupStackState.NotSetUp ) ) {
             return Response.status( Response.Status.OK )
-                           .entity( SetupStackState.SetUp.getMessage() )
+                           .entity( status.getMessage() )
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
+//        if( status.equals( SetupStackState.Destroying ) ) {
+//            return Response.status( Response.Status.OK )
+//                           .entity( SetupStackState.Destroying.getMessage() )
+//                           .type( MediaType.APPLICATION_JSON )
+//                           .build();
+//        }
+//        if( status.equals( SetupStackState.SettingUp ) ) {
+//            return Response.status( Response.Status.OK )
+//                           .entity( SetupStackState.SettingUp.getMessage() )
+//                           .type( MediaType.APPLICATION_JSON )
+//                           .build();
+//        }
+//        if( status.equals( SetupStackState.SetUp ) ) {
+//            return Response.status( Response.Status.OK )
+//                           .entity( SetupStackState.SetUp.getMessage() )
+//                           .type( MediaType.APPLICATION_JSON )
+//                           .build();
+//        }
 
         /** SetupStackState.NotSetUp */
         stackCoordinator.setupStack( commitId, artifactId, groupId, version, user, runnerCount
);
@@ -160,7 +167,7 @@ public class SetupResource extends TestableResource implements RestParams
{
             @QueryParam( RestParams.MODULE_VERSION ) String version,
             @QueryParam( RestParams.USERNAME ) String user,
             @Nullable @QueryParam( TestMode.TEST_MODE_PROPERTY ) String testMode
-                         ) {
+                          ) {
 
         if( inTestMode( testMode ) ) {
             LOG.info( "Calling /setup/status in test mode ..." );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/22df31b0/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/log/LogLayout.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/log/LogLayout.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/log/LogLayout.java
new file mode 100644
index 0000000..9e09eaf
--- /dev/null
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/log/LogLayout.java
@@ -0,0 +1,113 @@
+/*
+ *  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.usergrid.chop.webapp.view.log;
+
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.TextArea;
+
+
+public class LogLayout extends AbsoluteLayout {
+
+    private final static Logger LOG = LoggerFactory.getLogger( LogLayout.class );
+
+    private TextArea logArea;
+    private RandomAccessFile r;
+    private File file;
+
+
+    public LogLayout() {
+        initializeUIComponents();
+    }
+
+
+    private void initializeUIComponents() {
+        addLogArea();
+        addRefreshButton();
+    }
+
+
+    private void addLogArea() {
+        logArea = new TextArea( "Coordinator Logs" );
+
+        // TODO make this file point configurable
+        file = new File( "/var/log/chop-webapp.log" );
+        try {
+            r = new RandomAccessFile( file, "r" );
+        }
+        catch ( FileNotFoundException e ) {
+            LOG.error( "Error while accessing file {}: {}", file, e );
+        }
+        logArea.setWidth( "800px" );
+        logArea.setHeight( "530px" );
+        getApplicationLog();
+        addComponent( logArea, "left: 250px; top: 20px;" );
+    }
+
+
+    private void getApplicationLog() {
+        logArea.setReadOnly( false );
+
+        try {
+            String str = null;
+            StringBuilder log = new StringBuilder();
+            log.append( logArea.getValue() );
+            while( ( str = r.readLine() ) != null ) {
+                log.append( str );
+                log.append( System.getProperty( "line.separator" ) );
+            }
+            r.seek( r.getFilePointer() );
+            logArea.setValue( log.toString() );
+            logArea.setCursorPosition( log.toString().length() - 1 );
+
+        }
+        catch ( IOException e ) {
+            e.printStackTrace();
+        }
+        logArea.setReadOnly( true );
+    }
+
+
+    private void addRefreshButton()  {
+        Button button = new Button( "Refresh" );
+        button.setWidth( "100px" );
+        button.addClickListener( new Button.ClickListener() {
+            public void buttonClick( Button.ClickEvent event ) {
+                loadData();
+            }
+        } );
+        addComponent( button, "left: 585px; top: 570px;" );
+    }
+
+
+    private void loadData() {
+        getApplicationLog();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/22df31b0/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/main/MainView.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/main/MainView.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/main/MainView.java
index 4e0016b..8ebefe9 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/main/MainView.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/view/main/MainView.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.chop.webapp.view.main;
 
 import org.apache.usergrid.chop.webapp.service.chart.Params;
 import org.apache.usergrid.chop.webapp.view.chart.layout.*;
+import org.apache.usergrid.chop.webapp.view.log.LogLayout;
 import org.apache.usergrid.chop.webapp.view.module.ModuleListWindow;
 import org.apache.usergrid.chop.webapp.view.module.ModuleSelectListener;
 import org.apache.usergrid.chop.webapp.view.runner.RunnersLayout;
@@ -95,6 +96,12 @@ public class MainView extends UI implements ModuleSelectListener {
                 UI.getCurrent().addWindow( new UserListWindow( tabSheetManager ) );
             }
         });
+
+        addButton( mainLayout, 780, "Logs", new Button.ClickListener() {
+            public void buttonClick( Button.ClickEvent event ) {
+                tabSheetManager.addTab( new LogLayout(), "Logs" );
+            }
+        });
     }
 
 


Mime
View raw message