You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/01/04 15:53:21 UTC

svn commit: r1649347 [31/31] - in /lucene/dev/branches/lucene6005: ./ dev-tools/ dev-tools/idea/solr/contrib/dataimporthandler-extras/ dev-tools/idea/solr/contrib/extraction/ dev-tools/idea/solr/contrib/map-reduce/ dev-tools/idea/solr/contrib/velocity/...

Modified: lucene/dev/branches/lucene6005/solr/webapp/web/js/lib/jquery.sammy.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/webapp/web/js/lib/jquery.sammy.js?rev=1649347&r1=1649346&r2=1649347&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/webapp/web/js/lib/jquery.sammy.js (original)
+++ lucene/dev/branches/lucene6005/solr/webapp/web/js/lib/jquery.sammy.js Sun Jan  4 14:53:12 2015
@@ -48,7 +48,7 @@ THE SOFTWARE.
 
 
   // `Sammy` (also aliased as $.sammy) is not only the namespace for a
-  // number of prototypes, its also a top level method that allows for easy
+  // number of prototypes, it's also a top level method that allows for easy
   // creation/management of `Sammy.Application` instances. There are a
   // number of different forms for `Sammy()` but each returns an instance
   // of `Sammy.Application`. When a new instance is created using
@@ -1446,7 +1446,7 @@ THE SOFTWARE.
         }
         if (callback) { this.then(callback); }
         if (typeof location === 'string') {
-          // its a path
+          // it's a path
           is_json      = (location.match(/\.json$/) || options.json);
           should_cache = ((is_json && options.cache === true) || options.cache !== false);
           context.next_engine = context.event_context.engineFor(location);
@@ -1474,12 +1474,12 @@ THE SOFTWARE.
           }, options));
           return false;
         } else {
-          // its a dom/jQuery
+          // it's a dom/jQuery
           if (location.nodeType) {
             return location.innerHTML;
           }
           if (location.selector) {
-            // its a jQuery
+            // it's a jQuery
             context.next_engine = location.attr('data-engine');
             if (options.clone === false) {
               return location.remove()[0].innerHTML.toString();

Modified: lucene/dev/branches/lucene6005/solr/webapp/web/js/require.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/webapp/web/js/require.js?rev=1649347&r1=1649346&r2=1649347&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/webapp/web/js/require.js (original)
+++ lucene/dev/branches/lucene6005/solr/webapp/web/js/require.js Sun Jan  4 14:53:12 2015
@@ -4618,7 +4618,7 @@ jQuery.extend({
 					jQuery.error( "type property can't be changed" );
 				} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
 					// Setting the type on a radio button after the value resets the value in IE6-9
-					// Reset value to it's default in case type is set after value
+					// Reset value to its default in case type is set after value
 					// This is for element creation
 					var val = elem.value;
 					elem.setAttribute( "type", value );
@@ -6277,7 +6277,7 @@ var getText = Sizzle.getText = function(
 				// Replace IE's carriage returns
 				return elem.innerText.replace( rReturn, '' );
 			} else {
-				// Traverse it's children
+				// Traverse its children
 				for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
 					ret += getText( elem );
 				}

Modified: lucene/dev/branches/lucene6005/solr/webapp/web/js/scripts/cloud.js
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/webapp/web/js/scripts/cloud.js?rev=1649347&r1=1649346&r2=1649347&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/webapp/web/js/scripts/cloud.js (original)
+++ lucene/dev/branches/lucene6005/solr/webapp/web/js/scripts/cloud.js Sun Jan  4 14:53:12 2015
@@ -350,6 +350,106 @@ var generate_rgraph = function( graph_el
     );
 };
 
+var prepare_graph_data = function( response, graph_element, live_nodes, callback )
+{  
+    var state = null;
+    eval( 'state = ' + response.znode.data + ';' );
+    
+    var leaf_count = 0;
+    var graph_data = {
+      name: null,
+      children : []
+    };
+
+    for( var c in state )
+    {
+      var shards = [];
+      for( var s in state[c].shards )
+      {
+        var nodes = [];
+        for( var n in state[c].shards[s].replicas )
+        {
+          leaf_count++;
+          var replica = state[c].shards[s].replicas[n]
+
+          var uri = replica.base_url;
+          var parts = uri.match( /^(\w+:)\/\/(([\w\d\.-]+)(:(\d+))?)(.+)$/ );
+          var uri_parts = {
+            protocol: parts[1],
+            host: parts[2],
+            hostname: parts[3],
+            port: parseInt( parts[5] || 80, 10 ),
+            pathname: parts[6]
+          };
+          
+          helper_data.protocol.push( uri_parts.protocol );
+          helper_data.host.push( uri_parts.host );
+          helper_data.hostname.push( uri_parts.hostname );
+          helper_data.port.push( uri_parts.port );
+          helper_data.pathname.push( uri_parts.pathname );
+
+          var status = replica.state;
+
+          if( !live_nodes[replica.node_name] )
+          {
+            status = 'gone';
+          }
+
+          var node = {
+            name: uri,
+            data: {
+              type : 'node',
+              state : status,
+              leader : 'true' === replica.leader,
+              uri : uri_parts
+            }
+          };
+          nodes.push( node );
+        }
+
+        var shard = {
+          name: s,
+          data: {
+            type : 'shard'
+          },
+          children: nodes
+        };
+        shards.push( shard );
+      }
+
+      var collection = {
+        name: c,
+        data: {
+          type : 'collection'
+        },
+        children: shards
+      };
+      graph_data.children.push( collection );
+    }
+    
+    helper_data.protocol = $.unique( helper_data.protocol );
+    helper_data.host = $.unique( helper_data.host );
+    helper_data.hostname = $.unique( helper_data.hostname );
+    helper_data.port = $.unique( helper_data.port );
+    helper_data.pathname = $.unique( helper_data.pathname );
+
+    callback( graph_element, graph_data, leaf_count );  
+}
+
+var update_status_filter = function(filterType, filterVal) {
+  if (filterType == 'status') {
+    $( '#cloudGraphPagingStatusFilter' ).val(filterVal);
+    $( '#cloudGraphPagingStatusFilter' ).show();
+    $( '#cloudGraphPagingFilter' ).hide();
+    $( '#cloudGraphPagingFilter' ).val('');
+  } else {
+    $( '#cloudGraphPagingStatusFilter' ).hide();
+    $( '#cloudGraphPagingStatusFilter' ).val('');
+    $( '#cloudGraphPagingFilter' ).val(filterVal);
+    $( '#cloudGraphPagingFilter' ).show();                  
+  }  
+};
+
 var prepare_graph = function( graph_element, callback )
 {
   $.ajax
@@ -365,101 +465,82 @@ var prepare_graph = function( graph_elem
           live_nodes[response.tree[0].children[c].data.title] = true;
         }
 
+        var start = $( '#cloudGraphPagingStart' ).val();
+        var rows = $( '#cloudGraphPagingRows' ).val();
+        var clusterStateUrl = app.config.solr_path + '/zookeeper?wt=json&detail=true&path=%2Fclusterstate.json&view=graph';
+        if (start && rows)
+          clusterStateUrl += ('&start='+start+'&rows='+rows);
+        
+        var filterType = $( '#cloudGraphPagingFilterType' ).val();
+        if (filterType) {
+          var filter = (filterType == 'status')
+                         ? $( '#cloudGraphPagingStatusFilter' ).val() 
+                         : $( '#cloudGraphPagingFilter' ).val();  
+          if (filter)
+            clusterStateUrl += ('&filterType='+filterType+'&filter='+filter);
+        }
+                
         $.ajax
         (
           {
-            url : app.config.solr_path + '/zookeeper?wt=json&detail=true&path=%2Fclusterstate.json',
+            url : clusterStateUrl,
             dataType : 'json',
             context : graph_element,
             beforeSend : function( xhr, settings )
             {
-              this
-                .show();
+              this.show();
             },
             success : function( response, text_status, xhr )
-            {
-              var state = null;
-              eval( 'state = ' + response.znode.data + ';' );
-              
-              var leaf_count = 0;
-              var graph_data = {
-                name: null,
-                children : []
-              };
-
-              for( var c in state )
-              {
-                var shards = [];
-                for( var s in state[c].shards )
-                {
-                  var nodes = [];
-                  for( var n in state[c].shards[s].replicas )
-                  {
-                    leaf_count++;
-                    var replica = state[c].shards[s].replicas[n]
+            {              
+              prepare_graph_data(response, graph_element, live_nodes, callback)
 
-                    var uri = replica.base_url;
-                    var parts = uri.match( /^(\w+:)\/\/(([\w\d\.-]+)(:(\d+))?)(.+)$/ );
-                    var uri_parts = {
-                      protocol: parts[1],
-                      host: parts[2],
-                      hostname: parts[3],
-                      port: parseInt( parts[5] || 80, 10 ),
-                      pathname: parts[6]
-                    };
-                    
-                    helper_data.protocol.push( uri_parts.protocol );
-                    helper_data.host.push( uri_parts.host );
-                    helper_data.hostname.push( uri_parts.hostname );
-                    helper_data.port.push( uri_parts.port );
-                    helper_data.pathname.push( uri_parts.pathname );
-
-                    var status = replica.state;
-
-                    if( !live_nodes[replica.node_name] )
-                    {
-                      status = 'gone';
-                    }
-
-                    var node = {
-                      name: uri,
-                      data: {
-                        type : 'node',
-                        state : status,
-                        leader : 'true' === replica.leader,
-                        uri : uri_parts
-                      }
-                    };
-                    nodes.push( node );
-                  }
-
-                  var shard = {
-                    name: s,
-                    data: {
-                      type : 'shard'
-                    },
-                    children: nodes
-                  };
-                  shards.push( shard );
+              if (response.znode && response.znode.paging) {
+                var parr = response.znode.paging.split('|');
+                if (parr.length < 3) {
+                  $( '#cloudGraphPaging' ).hide();
+                  return;
                 }
-
-                var collection = {
-                  name: c,
-                  data: {
-                    type : 'collection'
-                  },
-                  children: shards
-                };
-                graph_data.children.push( collection );
-              }
-              
-              helper_data.protocol = $.unique( helper_data.protocol );
-              helper_data.host = $.unique( helper_data.host );
-              helper_data.hostname = $.unique( helper_data.hostname );
-              helper_data.port = $.unique( helper_data.port );
-              helper_data.pathname = $.unique( helper_data.pathname );
-
-              callback( graph_element, graph_data, leaf_count );
+                
+                var start = Math.max(parseInt(parr[0]),0);                  
+                var prevEnabled = (start > 0);
+                $('#cloudGraphPagingPrev').prop('disabled', !prevEnabled);
+                if (prevEnabled)
+                  $('#cloudGraphPagingPrev').show();                    
+                else
+                  $('#cloudGraphPagingPrev').hide();
+                
+                var rows = parseInt(parr[1])
+                var total = parseInt(parr[2])
+                $( '#cloudGraphPagingStart' ).val(start);
+                $( '#cloudGraphPagingRows' ).val(rows);
+                if (rows == -1)
+                  $( '#cloudGraphPaging' ).hide();
+                                  
+                var filterType = parr.length > 3 ? parr[3] : '';
+                if (filterType == '' || filterType == 'none') filterType = 'status';
+                
+                $( '#cloudGraphPagingFilterType' ).val(filterType);                  
+                var filter = parr.length > 4 ? parr[4] : '';
+
+                update_status_filter(filterType, filter);
+                
+                var page = Math.floor(start/rows)+1;
+                var pages = Math.ceil(total/rows);
+                var last = Math.min(start+rows,total);
+                var nextEnabled = (last < total);                  
+                $('#cloudGraphPagingNext').prop('disabled', !nextEnabled);
+                if (nextEnabled)
+                  $('#cloudGraphPagingNext').show();
+                else
+                  $('#cloudGraphPagingNext').hide();                    
+                
+                var status = (total > 0) 
+                               ? 'Collections '+(start+1)+' - '+last+' of '+total+'. ' 
+                               : 'No collections found.';
+                $( '#cloudGraphPagingStatus' ).html(status);
+              } else {
+                $( '#cloudGraphPaging' ).hide();
+              }            
             },
             error : function( xhr, text_status, error_thrown)
             {
@@ -662,6 +743,21 @@ var init_tree = function( tree_element )
   );
 };
 
+// updates the starting position for paged navigation
+// and then rebuilds the graph based on the selected page
+var update_start = function(direction, cloud_element) {
+  var start = $( '#cloudGraphPagingStart' ).val();
+  var rows = $( '#cloudGraphPagingRows' ).val();
+  var startAt = start ? parseInt(start) : 0;
+  var numRows = rows ? parseInt(rows) : 20;
+  var newStart = Math.max(startAt + (rows * direction),0); 
+  $( '#cloudGraphPagingStart' ).val(newStart);
+  
+  var graph_element = $( '#graph-content', cloud_element );
+  $( '#canvas', graph_element).empty();
+  init_graph( graph_element );  
+};
+
 // #/~cloud
 sammy.get
 (
@@ -704,6 +800,45 @@ sammy.get
             {
               $( this ).addClass( 'active' );
               init_graph( $( '#graph-content', cloud_element ) );
+              
+              $('#cloudGraphPagingNext').click(function() {
+                update_start(1, cloud_element);                  
+              });
+              
+              $('#cloudGraphPagingPrev').click(function() {
+                update_start(-1, cloud_element);                                    
+              });              
+
+              $('#cloudGraphPagingRows').change(function() {
+                var rows = $( this ).val();
+                if (!rows || rows == '')
+                  $( this ).val("20");
+                
+                // ? restart the start position when rows changes?
+                $( '#cloudGraphPagingStart' ).val(0);                  
+                update_start(-1, cloud_element);                
+              });              
+              
+              $('#cloudGraphPagingFilter').change(function() {
+                var filter = $( this ).val();
+                // reset the start position when the filter changes
+                $( '#cloudGraphPagingStart' ).val(0);
+                update_start(-1, cloud_element);
+              });
+
+              $( '#cloudGraphPagingStatusFilter' ).show();
+              $( '#cloudGraphPagingFilter' ).hide();
+              
+              $('#cloudGraphPagingFilterType').change(function() {
+                update_status_filter($( this ).val(), '');
+              });
+              
+              $('#cloudGraphPagingStatusFilter').change(function() {
+                // just reset the paged navigation controls based on this update
+                $( '#cloudGraphPagingStart' ).val(0);                  
+                update_start(-1, cloud_element);                                    
+              });
+              
             }
           );
 
@@ -714,6 +849,8 @@ sammy.get
             'activate',
             function( event )
             {
+              $( "#cloudGraphPaging" ).hide(); // TODO: paging for rgraph too
+              
               $( this ).addClass( 'active' );
               init_rgraph( $( '#graph-content', cloud_element ) );
             }

Modified: lucene/dev/branches/lucene6005/solr/webapp/web/tpl/cloud.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/webapp/web/tpl/cloud.html?rev=1649347&r1=1649346&r2=1649347&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/webapp/web/tpl/cloud.html (original)
+++ lucene/dev/branches/lucene6005/solr/webapp/web/tpl/cloud.html Sun Jan  4 14:53:12 2015
@@ -50,6 +50,28 @@ limitations under the License.
         </ul>
       </div>
 
+      <div style="width: 100%; text-align: center;">
+        <div id="cloudGraphPaging">
+         <button id="cloudGraphPagingPrev">&lt; Previous</button>
+         <input id="cloudGraphPagingStart" type="hidden" name="start" /> 
+         <span id="cloudGraphPagingStatus"></span>&nbsp;
+         Filter by:&nbsp;<select id="cloudGraphPagingFilterType">
+           <option value="status">Status</option>
+           <option value="name">Name</option>
+         </select>&nbsp;
+         <select id="cloudGraphPagingStatusFilter">
+           <option value=""> - Any - </option>
+           <option value="healthy">Healthy</option>
+           <option value="degraded">Degraded</option>
+           <option value="downed_shard">Downed Shard</option>
+           <option value="recovering">Replica in Recovery</option>
+         </select>         
+         <input id="cloudGraphPagingFilter" type="text" size="10" name="filter" />&nbsp;
+         Show <input id="cloudGraphPagingRows" type="text" size="2" name="rows" /> per page.
+         <button id="cloudGraphPagingNext">Next &gt;</button>
+        </div>
+      </div>
+
     </div>
 
   </div>
@@ -62,4 +84,4 @@ limitations under the License.
     <pre class="debug"></pre>
   </div>
 
-</div>
\ No newline at end of file
+</div>