[Groonga-commit] groonga/gcs [master] Make gcs-describe-domain command http-based

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Oct 15 15:58:31 JST 2012


YUKI Hiroshi	2012-10-15 15:58:31 +0900 (Mon, 15 Oct 2012)

  New Revision: a4740af539a36503f8dbec0acfc87b6ef3fb6191
  https://github.com/groonga/gcs/commit/a4740af539a36503f8dbec0acfc87b6ef3fb6191

  Log:
    Make gcs-describe-domain command http-based

  Modified files:
    bin/gcs-describe-domain
    lib/command-line.js
    test/gcs-commands.test.js

  Modified: bin/gcs-describe-domain (+15 -53)
===================================================================
--- bin/gcs-describe-domain    2012-10-15 15:50:15 +0900 (be8426d)
+++ bin/gcs-describe-domain    2012-10-15 15:58:31 +0900 (4e0bf92)
@@ -13,45 +13,6 @@ commandLine
           String)
   .parse();
 
-var hostPort = '127.0.0.1.xip.io:7575';
-
-function report(domain) {
-  console.log('=== Domain Summary ===');
-  console.log('Domain Name: %s',
-              domain.name);
-  console.log('Document Service endpoint: %s',
-              domain.getDocumentsEndpoint(hostPort));
-  console.log('Search Service endpoint: %s',
-              domain.getSearchEndpoint(hostPort));
-  console.log('SearchInstanceType: %s',
-              domain.searchInstanceType);
-  console.log('SearchPartitionCount: %s',
-              domain.searchPartitionCount);
-  console.log('SearchInstanceCount: %s',
-              domain.searchInstanceCount);
-  console.log('Searchable Documents: %s',
-              domain.searchableDocumentsCount);
-  console.log('Current configuration changes require a call to ' +
-                'IndexDocuments: %s',
-              domain.requiresIndexDocuments ? 'Yes' : 'No' );
-
-  // additional information for the default search field!
-  var field = domain.defaultSearchField;
-  if (field)
-    console.log('Default search field: %s', field.name);
-
-  console.log('');
-  console.log('=== Domain Configuration ===');
-
-  console.log('');
-  console.log('Fields:');
-  console.log('=======');
-  domain.indexFields.forEach(function(field) {
-    console.log(field.summary);
-  });
-  console.log('======================');
-}
-
 function reportStatus(domain, indexFields) {
   console.log('=== Domain Summary ===');
   console.log('Domain Name: %s',
@@ -89,27 +50,28 @@ function reportStatus(domain, indexFields) {
   console.log('======================');
 }
 
-function outputNotesForHostAndPort() {
-  console.log('*Note: the hostname and the port number is detected from ' +
-              'the default options. If you run the service with your ' +
-              'favorite host name and port number, then use it instead of ' +
-              'default information.');
-}
-
 var domainName = commandLine.domainName;
 if (domainName) {
   commandLine.getDomainStatus(domainName, function(error, domain) {
     commandLine.getIndexFieldStatuses(domainName, function(error, indexFields) {
       reportStatus(domain, indexFields);
-      outputNotesForHostAndPort();
     });
   });
 } else {
-  var domains = CLI.Domain.getAll(commandLine.context);
-  domains.forEach(function(domain, index) {
-    if (index) console.log('');
-    report(domain);
+  commandLine.getDomainStatuses(null, function(error, domains) {
+    var statuses = {};
+    var statusPreparedCount = 0;
+    domains.slice(0).forEach(function(domain) {
+      statuses[domain.DomainName] = { domain: domain };
+      commandLine.getIndexFieldStatuses(domain.DomainName, function(error, indexFields) {
+        statuses[domain.DomainName].indexFields = indexFields;
+        statusPreparedCount++;
+        if (statusPreparedCount == domains.length) {
+          statuses.forEach(function(status) {
+            reportStatus(status.domain, status.indexFields);
+          });
+        }
+      });
+    });
   });
-  if (domains.length)
-    outputNotesForHostAndPort();
 }

  Modified: lib/command-line.js (+1 -1)
===================================================================
--- lib/command-line.js    2012-10-15 15:50:15 +0900 (d4b4fb3)
+++ lib/command-line.js    2012-10-15 15:58:31 +0900 (8bf2e45)
@@ -145,7 +145,7 @@ CommandLineInterface.prototype = {
 
   getDomainStatuses: function(options, callback) {
     this.cloudSearch.DescribeDomains(
-      options,
+      options || {},
       function(error, response) {
         if (error) {
           console.log('Unexpected error: ' + JSON.stringify(error));

  Modified: test/gcs-commands.test.js (+4 -13)
===================================================================
--- test/gcs-commands.test.js    2012-10-15 15:50:15 +0900 (9bc25f0)
+++ test/gcs-commands.test.js    2012-10-15 15:58:31 +0900 (c858db8)
@@ -206,12 +206,7 @@ suite('gcs-describe-domain', function() {
                              '=======\n' +
                              ageField.summary + '\n' +
                              nameField.summary +'\n' +
-                             '======================\n' +
-                             '*Note: the hostname and the port number is ' +
-                             'detected from the default options. If you run ' +
-                             'the service with your favorite host name and ' +
-                             'port number, then use it instead of default ' +
-                             'information.\n' });
+                             '======================\n' });
 
         done();
       })
@@ -226,7 +221,8 @@ suite('gcs-describe-domain', function() {
     utils
       .run('gcs-describe-domain',
            '--show-all',
-           '--database-path', temporaryDatabase.path)
+           '--port', utils.testPort,
+           '--base-host', 'localhost:' + utils.testPort)
       .next(function(result) {
         var domain1 = new Domain('domain1', context);
         var domain2 = new Domain('domain2', context);
@@ -269,12 +265,7 @@ suite('gcs-describe-domain', function() {
                              '\n' +
                              'Fields:\n' +
                              '=======\n' +
-                             '======================\n' +
-                             '*Note: the hostname and the port number is ' +
-                             'detected from the default options. If you run ' +
-                             'the service with your favorite host name and ' +
-                             'port number, then use it instead of default ' +
-                             'information.\n' });
+                             '======================\n' });
 
         done();
       })
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index