From b9a4ca3a2a5306b26b5c52a9cc60adf80c2123a4 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Fri, 30 Dec 2016 09:11:56 -0500 Subject: [PATCH 01/13] ACCUMULO-4061 Tablet Servers now save the version number when they get created --- .../master/thrift/TabletServerStatus.java | 249 ++++++++++++++---- .../apache/accumulo/tserver/TabletServer.java | 12 + 2 files changed, 215 insertions(+), 46 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java b/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java index c0756cdfb63..06455b6c17e 100644 --- a/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java +++ b/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java @@ -22,6 +22,34 @@ */ package org.apache.accumulo.core.master.thrift; +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.commons.io.filefilter.OrFileFilter; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)") public class TabletServerStatus implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { @@ -41,9 +69,13 @@ public class TabletServerStatus implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new TabletServerStatusStandardSchemeFactory()); + schemes.put(TupleScheme.class, new TabletServerStatusTupleSchemeFactory()); + } public java.util.Map tableMap; // required public long lastContact; // required @@ -58,7 +90,8 @@ public class TabletServerStatus implements org.apache.thrift.TBase logSorts; // required public long flushs; // required public long syncs; // required - public java.util.List bulkImports; // required + public List bulkImports; // required + public String version; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -75,7 +108,8 @@ public enum _Fields implements org.apache.thrift.TFieldIdEnum { LOG_SORTS((short)14, "logSorts"), FLUSHS((short)15, "flushs"), SYNCS((short)16, "syncs"), - BULK_IMPORTS((short)17, "bulkImports"); + BULK_IMPORTS((short)17, "bulkImports"), + VERSION((short)18, "version"); private static final java.util.Map byName = new java.util.HashMap(); @@ -118,6 +152,8 @@ public static _Fields findByThriftId(int fieldId) { return SYNCS; case 17: // BULK_IMPORTS return BULK_IMPORTS; + case 18: // VERSION + return VERSION; default: return null; } @@ -204,7 +240,9 @@ public java.lang.String getFieldName() { tmpMap.put(_Fields.BULK_IMPORTS, new org.apache.thrift.meta_data.FieldMetaData("bulkImports", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, BulkImportStatus.class)))); - metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TabletServerStatus.class, metaDataMap); } @@ -225,7 +263,8 @@ public TabletServerStatus( java.util.List logSorts, long flushs, long syncs, - java.util.List bulkImports) + List bulkImports, + String version) { this(); this.tableMap = tableMap; @@ -252,6 +291,7 @@ public TabletServerStatus( this.syncs = syncs; setSyncsIsSet(true); this.bulkImports = bulkImports; + this.version = version; } /** @@ -301,6 +341,7 @@ public TabletServerStatus(TabletServerStatus other) { } this.bulkImports = __this__bulkImports; } + this.version = other.version; } public TabletServerStatus deepCopy() { @@ -333,6 +374,7 @@ public void clear() { setSyncsIsSet(false); this.syncs = 0; this.bulkImports = null; + this.version = null; } public int getTableMapSize() { @@ -701,6 +743,30 @@ public void setBulkImportsIsSet(boolean value) { this.bulkImports = null; } } + + public String getVersion() { + return this.version; + } + + public TabletServerStatus setVersion(String version) { + this.version = version; + return this; + } + + public void unsetVersion() { + this.version = null; + } + + /** Returns true if field version is set (has been assigned a value) and false otherwise */ + public boolean isSetVersion() { + return this.version != null; + } + + public void setVersionIsSet(boolean value) { + if (!value) { + this.version = null; + } + } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { @@ -815,6 +881,14 @@ public void setFieldValue(_Fields field, java.lang.Object value) { setBulkImports((java.util.List)value); } break; + + case VERSION: + if (value == null) { + unsetVersion(); + } else { + setVersion((String)version); + } + break; } } @@ -862,6 +936,9 @@ public java.lang.Object getFieldValue(_Fields field) { case BULK_IMPORTS: return getBulkImports(); + + case VERSION: + return getVersion(); } throw new java.lang.IllegalStateException(); @@ -902,6 +979,8 @@ public boolean isSet(_Fields field) { return isSetSyncs(); case BULK_IMPORTS: return isSetBulkImports(); + case VERSION: + return isSetVersion(); } throw new java.lang.IllegalStateException(); } @@ -1052,45 +1131,84 @@ public boolean equals(TabletServerStatus that) { @Override public int hashCode() { - int hashCode = 1; - - hashCode = hashCode * 8191 + ((isSetTableMap()) ? 131071 : 524287); - if (isSetTableMap()) - hashCode = hashCode * 8191 + tableMap.hashCode(); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(lastContact); - - hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287); - if (isSetName()) - hashCode = hashCode * 8191 + name.hashCode(); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(osLoad); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(holdTime); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(lookups); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(indexCacheHits); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(indexCacheRequest); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(dataCacheHits); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(dataCacheRequest); - - hashCode = hashCode * 8191 + ((isSetLogSorts()) ? 131071 : 524287); - if (isSetLogSorts()) - hashCode = hashCode * 8191 + logSorts.hashCode(); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(flushs); - - hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(syncs); - - hashCode = hashCode * 8191 + ((isSetBulkImports()) ? 131071 : 524287); - if (isSetBulkImports()) - hashCode = hashCode * 8191 + bulkImports.hashCode(); - - return hashCode; + List list = new ArrayList(); + + boolean present_tableMap = true && (isSetTableMap()); + list.add(present_tableMap); + if (present_tableMap) + list.add(tableMap); + + boolean present_lastContact = true; + list.add(present_lastContact); + if (present_lastContact) + list.add(lastContact); + + boolean present_name = true && (isSetName()); + list.add(present_name); + if (present_name) + list.add(name); + + boolean present_osLoad = true; + list.add(present_osLoad); + if (present_osLoad) + list.add(osLoad); + + boolean present_holdTime = true; + list.add(present_holdTime); + if (present_holdTime) + list.add(holdTime); + + boolean present_lookups = true; + list.add(present_lookups); + if (present_lookups) + list.add(lookups); + + boolean present_indexCacheHits = true; + list.add(present_indexCacheHits); + if (present_indexCacheHits) + list.add(indexCacheHits); + + boolean present_indexCacheRequest = true; + list.add(present_indexCacheRequest); + if (present_indexCacheRequest) + list.add(indexCacheRequest); + + boolean present_dataCacheHits = true; + list.add(present_dataCacheHits); + if (present_dataCacheHits) + list.add(dataCacheHits); + + boolean present_dataCacheRequest = true; + list.add(present_dataCacheRequest); + if (present_dataCacheRequest) + list.add(dataCacheRequest); + + boolean present_logSorts = true && (isSetLogSorts()); + list.add(present_logSorts); + if (present_logSorts) + list.add(logSorts); + + boolean present_flushs = true; + list.add(present_flushs); + if (present_flushs) + list.add(flushs); + + boolean present_syncs = true; + list.add(present_syncs); + if (present_syncs) + list.add(syncs); + + boolean present_bulkImports = true && (isSetBulkImports()); + list.add(present_bulkImports); + if (present_bulkImports) + list.add(bulkImports); + + boolean present_version = true && (isSetVersion()); + list.add(present_version); + if (present_version) + list.add(version); + + return list.hashCode(); } @Override @@ -1241,6 +1359,16 @@ public int compareTo(TabletServerStatus other) { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetVersion()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.version, other.version); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -1332,6 +1460,14 @@ public java.lang.String toString() { sb.append(this.bulkImports); } first = false; + if (!first) sb.append(", "); + sb.append("version:"); + if (this.version == null) { + sb.append("null"); + } else { + sb.append(this.version); + } + first = false; sb.append(")"); return sb.toString(); } @@ -1524,6 +1660,15 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, TabletServerStatus org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 18: // VERSION + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.version = iprot.readString(); + struct.setVersionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1611,6 +1756,11 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, TabletServerStatus } oprot.writeFieldEnd(); } + if (struct.version != null) { + oprot.writeFieldBegin(VERSION_FIELD_DESC); + oprot.writeString(struct.version); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1733,6 +1883,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus } } } + if (struct.isSetVersion()) { + optionals.set(16); + } } @Override @@ -1827,6 +1980,10 @@ public void read(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus s } struct.setBulkImportsIsSet(true); } + if (incoming.get(14)) { + struct.version = iprot.readString(); + struct.setVersionIsSet(true); + } } } diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java index 64e3bcdc64c..550881cbac4 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java @@ -320,6 +320,8 @@ public Metrics getMinCMetrics() { private final BlockingDeque masterMessages = new LinkedBlockingDeque<>(); private Thread majorCompactorThread; + + private String version; private HostAndPort replicationAddress; private HostAndPort clientAddress; @@ -347,6 +349,7 @@ public Metrics getMinCMetrics() { public TabletServer(Instance instance, ServerConfigurationFactory confFactory, VolumeManager fs) throws IOException { super(instance, confFactory); + this.version = Constants.VERSION; this.confFactory = confFactory; this.fs = fs; final AccumuloConfiguration aconf = getConfiguration(); @@ -413,6 +416,14 @@ public void run() { authKeyWatcher = null; } } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } private static long jitter(long ms) { Random r = new Random(); @@ -3053,6 +3064,7 @@ public TabletServerStatus getStats(Map> scanCoun result.bulkImports = new ArrayList<>(); result.bulkImports.addAll(clientHandler.getBulkLoadStatus()); result.bulkImports.addAll(bulkImportStatus.getBulkLoadStatus()); + result.version = this.version; return result; } From d123e4cb64afb63a6aac581b715c5d6214c744b4 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Wed, 4 Jan 2017 10:26:05 -0500 Subject: [PATCH 02/13] ACCUMULO-4061 Modified thrift file --- core/src/main/thrift/master.thrift | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/thrift/master.thrift b/core/src/main/thrift/master.thrift index fbacc663637..86338909e0a 100644 --- a/core/src/main/thrift/master.thrift +++ b/core/src/main/thrift/master.thrift @@ -85,6 +85,7 @@ struct TabletServerStatus { 15:i64 flushs 16:i64 syncs 17:list bulkImports + 18:string version } enum MasterState { From 73b7342f0d2109b8a2d5b3603ca64932d9599907 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Wed, 4 Jan 2017 10:26:38 -0500 Subject: [PATCH 03/13] ACCUMULO-4061 Re-generated java file --- .../master/thrift/TabletServerStatus.java | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java b/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java index 06455b6c17e..d7131db41f8 100644 --- a/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java +++ b/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java @@ -29,7 +29,6 @@ import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import org.apache.thrift.protocol.TProtocolException; -import org.apache.commons.io.filefilter.OrFileFilter; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; import org.apache.thrift.async.AsyncMethodCallback; @@ -70,7 +69,7 @@ public class TabletServerStatus implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { schemes.put(StandardScheme.class, new TabletServerStatusStandardSchemeFactory()); @@ -91,7 +90,7 @@ public class TabletServerStatus implements org.apache.thrift.TBase bulkImports; // required - public String version; + public String version; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -240,7 +239,7 @@ public java.lang.String getFieldName() { tmpMap.put(_Fields.BULK_IMPORTS, new org.apache.thrift.meta_data.FieldMetaData("bulkImports", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, BulkImportStatus.class)))); - tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TabletServerStatus.class, metaDataMap); @@ -341,7 +340,9 @@ public TabletServerStatus(TabletServerStatus other) { } this.bulkImports = __this__bulkImports; } - this.version = other.version; + if (other.isSetVersion()) { + this.version = other.version; + } } public TabletServerStatus deepCopy() { @@ -743,7 +744,7 @@ public void setBulkImportsIsSet(boolean value) { this.bulkImports = null; } } - + public String getVersion() { return this.version; } @@ -881,12 +882,12 @@ public void setFieldValue(_Fields field, java.lang.Object value) { setBulkImports((java.util.List)value); } break; - + case VERSION: if (value == null) { unsetVersion(); } else { - setVersion((String)version); + setVersion((String)value); } break; @@ -936,7 +937,7 @@ public java.lang.Object getFieldValue(_Fields field) { case BULK_IMPORTS: return getBulkImports(); - + case VERSION: return getVersion(); @@ -1126,6 +1127,15 @@ public boolean equals(TabletServerStatus that) { return false; } + boolean this_present_version = true && this.isSetVersion(); + boolean that_present_version = true && that.isSetVersion(); + if (this_present_version || that_present_version) { + if (!(this_present_version && that_present_version)) + return false; + if (!this.version.equals(that.version)) + return false; + } + return true; } @@ -1202,7 +1212,7 @@ public int hashCode() { list.add(present_bulkImports); if (present_bulkImports) list.add(bulkImports); - + boolean present_version = true && (isSetVersion()); list.add(present_version); if (present_version) @@ -1667,8 +1677,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, TabletServerStatus } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } - break; - + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1821,7 +1830,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus if (struct.isSetBulkImports()) { optionals.set(13); } - oprot.writeBitSet(optionals, 14); + if (struct.isSetVersion()) { + optionals.set(14); + } + oprot.writeBitSet(optionals, 15); if (struct.isSetTableMap()) { { oprot.writeI32(struct.tableMap.size()); @@ -1884,14 +1896,14 @@ public void write(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus } } if (struct.isSetVersion()) { - optionals.set(16); + oprot.writeString(struct.version); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(14); + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(15); if (incoming.get(0)) { { org.apache.thrift.protocol.TMap _map16 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); From 7ea87f62de862d4583b5191f00ca5c1ec37820c5 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Wed, 4 Jan 2017 10:32:33 -0500 Subject: [PATCH 04/13] ACCUMULO-4061 Removed set method --- .../org/apache/accumulo/tserver/TabletServer.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java index 550881cbac4..8a0a4ef15c1 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java @@ -320,8 +320,6 @@ public Metrics getMinCMetrics() { private final BlockingDeque masterMessages = new LinkedBlockingDeque<>(); private Thread majorCompactorThread; - - private String version; private HostAndPort replicationAddress; private HostAndPort clientAddress; @@ -416,13 +414,9 @@ public void run() { authKeyWatcher = null; } } - + public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; + return Constants.VERSION; } private static long jitter(long ms) { @@ -3064,7 +3058,7 @@ public TabletServerStatus getStats(Map> scanCoun result.bulkImports = new ArrayList<>(); result.bulkImports.addAll(clientHandler.getBulkLoadStatus()); result.bulkImports.addAll(bulkImportStatus.getBulkLoadStatus()); - result.version = this.version; + result.version = getVersion(); return result; } From ebda38857f698ebc253f1707d308648b29c25f50 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Wed, 4 Jan 2017 15:03:34 -0500 Subject: [PATCH 05/13] ACCUMULO-4061 Ping on the shell returns Accumulo version --- .../core/client/admin/InstanceOperations.java | 10 +++++ .../client/impl/InstanceOperationsImpl.java | 38 +++++++++++++++++++ .../client/mock/MockInstanceOperations.java | 5 +++ .../accumulo/shell/commands/PingIterator.java | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java index 79b430ceec5..cfaf0fc0293 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java @@ -80,6 +80,16 @@ public interface InstanceOperations { List getTabletServers(); + /** + * Return the version the selected tablet server in the accumulo instance + * + * @param tserver + * The tablet server address should be of the form {@code :} + * @return The version of the selected tablet server. + */ + + String getTabletServerVersion(String tserver) throws AccumuloException; + /** * List the active scans on tablet server. * diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java index 9b88473774f..f34a9434151 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java @@ -37,6 +37,8 @@ import org.apache.accumulo.core.client.impl.thrift.ConfigurationType; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.master.thrift.MasterClientService; +import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; +import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.rpc.ThriftUtil; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client; @@ -207,6 +209,42 @@ public void ping(String tserver) throws AccumuloException { } } + @Override + public String getTabletServerVersion(String tserver) throws AccumuloException { + String version = null; + MasterMonitorInfo mmi = null; + boolean retry = true; + + while (retry) { + MasterClientService.Iface client = null; + try { + client = MasterClient.getConnection(context); + if (client != null) { + mmi = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds()); + retry = false; + } else { + mmi = null; + } + } catch (Exception e) { + mmi = null; + } finally { + if (client != null) { + MasterClient.close(client); + } + } + } + if (mmi != null) { + for (TabletServerStatus ts : mmi.getTServerInfo()) { + if (tserver.equals(ts.getName())) { + version = ts.getVersion(); + break; + } + } + } + + return version; + } + @Override public void waitForBalance() throws AccumuloException { try { diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java index e2641044c4e..b91754f7d55 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java @@ -94,4 +94,9 @@ public void ping(String tserver) throws AccumuloException { @Override public void waitForBalance() throws AccumuloException {} + + @Override + public String getTabletServerVersion(String tserver) throws AccumuloException { + return null; + } } diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java index 4072ec050b9..8d6159c5fdb 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java @@ -43,11 +43,11 @@ public String next() { try { instanceOps.ping(tserver); + return tserver + " OK " + instanceOps.getTabletServerVersion(tserver); } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } - return tserver + " OK"; } @Override From d0620c44553b51ee2e03fa6027084b409e90ab1e Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Thu, 5 Jan 2017 08:35:31 -0500 Subject: [PATCH 06/13] ACCUMULO-4061 Mock version method now returns Constants.VERSION --- .../accumulo/core/client/mock/MockInstanceOperations.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java index b91754f7d55..a7622388b69 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; +import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.admin.ActiveCompaction; @@ -97,6 +98,6 @@ public void waitForBalance() throws AccumuloException {} @Override public String getTabletServerVersion(String tserver) throws AccumuloException { - return null; + return Constants.VERSION; } } From c1f9ac6af86515c2a817bd28855edbbad906e191 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Fri, 6 Jan 2017 08:29:25 -0500 Subject: [PATCH 07/13] ACCUMULO-4558 Added new command to display tablet server status --- .../accumulo/core/client/TServerStatus.java | 183 ++++++++++++++++++ .../accumulo/core/client/TableInfoUtil.java | 88 +++++++++ .../core/client/admin/InstanceOperations.java | 13 +- .../client/impl/InstanceOperationsImpl.java | 45 +++-- .../client/mock/MockInstanceOperations.java | 6 +- .../java/org/apache/accumulo/shell/Shell.java | 3 +- .../accumulo/shell/commands/PingIterator.java | 4 +- .../commands/TabletServerStatusCommand.java | 86 ++++++++ .../commands/TabletServerStatusIterator.java | 88 +++++++++ 9 files changed, 492 insertions(+), 24 deletions(-) create mode 100644 core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java create mode 100644 core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java create mode 100644 shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java create mode 100644 shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java diff --git a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java new file mode 100644 index 00000000000..a50d31c7cfa --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java @@ -0,0 +1,183 @@ +/* + * 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.accumulo.core.client; + +/** + * This exception is thrown if a table is deleted after an operation starts. + * + * For example if table A exist when a scan is started, but is deleted during the scan then this exception is thrown. + * + */ + +public class TServerStatus extends RuntimeException { + + private String name, version; + int hostedTablets; + long lastContact, entries, holdTime; + double ingest, query, indexHitRate, dataHitRate, osLoad; + Integer scans, minor, major; + + public TServerStatus() { + name = ""; + hostedTablets = 0; + lastContact = 0l; + entries = 0l; + ingest = 0.0; + query = 0.0; + holdTime = 0l; + scans = null; + minor = null; + major = null; + indexHitRate = 0.0; + dataHitRate = 0.0; + osLoad = 0.0; + version = ""; + } + + public TServerStatus(String name, int hostedTablets, long lastContact, long entries, double ingest, double query, + long holdTime, Integer scans, Integer minor, Integer major, double indexHitRate, double dataHitRate, double osLoad, + String version) { + this.name = name; + this.hostedTablets = hostedTablets; + this.lastContact = lastContact; + this.entries = entries; + this.ingest = ingest; + this.query = query; + this.holdTime = holdTime; + this.scans = scans; + this.minor = minor; + this.major = major; + this.indexHitRate = indexHitRate; + this.dataHitRate = dataHitRate; + this.osLoad = osLoad; + this.version = version; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public int getHostedTablets() { + return hostedTablets; + } + + public void setHostedTablets(int hostedTablets) { + this.hostedTablets = hostedTablets; + } + + public long getLastContact() { + return lastContact; + } + + public void setLastContact(long lastContact) { + this.lastContact = lastContact; + } + + public long getEntries() { + return entries; + } + + public void setEntries(long entries) { + this.entries = entries; + } + + public long getHoldTime() { + return holdTime; + } + + public void setHoldTime(long holdTime) { + this.holdTime = holdTime; + } + + public double getIngest() { + return ingest; + } + + public void setIngest(double ingest) { + this.ingest = ingest; + } + + public double getQuery() { + return query; + } + + public void setQuery(double query) { + this.query = query; + } + + public double getIndexHitRate() { + return indexHitRate; + } + + public void setIndexHitRate(double indexHitRate) { + this.indexHitRate = indexHitRate; + } + + public double getDataHitRate() { + return dataHitRate; + } + + public void setDataHitRate(double dataHitRate) { + this.dataHitRate = dataHitRate; + } + + public double getOsLoad() { + return osLoad; + } + + public void setOsLoad(double osLoad) { + this.osLoad = osLoad; + } + + public Integer getScans() { + return scans; + } + + public void setScans(Integer scans) { + this.scans = scans; + } + + public Integer getMinor() { + return minor; + } + + public void setMinor(Integer minor) { + this.minor = minor; + } + + public Integer getMajor() { + return major; + } + + public void setMajor(Integer major) { + this.major = major; + } + + +} diff --git a/core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java b/core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java new file mode 100644 index 00000000000..eabc6701e62 --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java @@ -0,0 +1,88 @@ +/* + * 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.accumulo.core.client; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.accumulo.core.master.thrift.Compacting; +import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; +import org.apache.accumulo.core.master.thrift.TableInfo; +import org.apache.accumulo.core.master.thrift.TabletServerStatus; + +/** + * + */ +public class TableInfoUtil { + + public static void add(TableInfo total, TableInfo more) { + if (total.minors == null) + total.minors = new Compacting(); + if (total.majors == null) + total.majors = new Compacting(); + if (total.scans == null) + total.scans = new Compacting(); + if (more.minors != null) { + total.minors.running += more.minors.running; + total.minors.queued += more.minors.queued; + } + if (more.majors != null) { + total.majors.running += more.majors.running; + total.majors.queued += more.majors.queued; + } + if (more.scans != null) { + total.scans.running += more.scans.running; + total.scans.queued += more.scans.queued; + } + total.onlineTablets += more.onlineTablets; + total.recs += more.recs; + total.recsInMemory += more.recsInMemory; + total.tablets += more.tablets; + total.ingestRate += more.ingestRate; + total.ingestByteRate += more.ingestByteRate; + total.queryRate += more.queryRate; + total.queryByteRate += more.queryByteRate; + total.scanRate += more.scanRate; + } + + public static TableInfo summarizeTableStats(TabletServerStatus status) { + TableInfo summary = new TableInfo(); + summary.majors = new Compacting(); + summary.minors = new Compacting(); + summary.scans = new Compacting(); + for (TableInfo rates : status.tableMap.values()) { + TableInfoUtil.add(summary, rates); + } + return summary; + } + + public static Map summarizeTableStats(MasterMonitorInfo mmi) { + Map compactingByTable = new HashMap<>(); + if (mmi != null && mmi.tServerInfo != null) { + for (TabletServerStatus status : mmi.tServerInfo) { + if (status != null && status.tableMap != null) { + for (String table : status.tableMap.keySet()) { + Double holdTime = compactingByTable.get(table); + compactingByTable.put(table, Math.max(holdTime == null ? 0. : holdTime.doubleValue(), status.holdTime)); + } + } + } + } + return compactingByTable; + } + +} diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java index cfaf0fc0293..e7dd58d8fc3 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java @@ -21,6 +21,7 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.client.TServerStatus; /** * @@ -79,16 +80,14 @@ public interface InstanceOperations { */ List getTabletServers(); - + /** - * Return the version the selected tablet server in the accumulo instance + * List the tablet server status * - * @param tserver - * The tablet server address should be of the form {@code :} - * @return The version of the selected tablet server. + * @return A list of tablet server status. */ - - String getTabletServerVersion(String tserver) throws AccumuloException; + + List getTabletServerStatus() throws AccumuloException; /** * List the active scans on tablet server. diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java index f34a9434151..3f43bb64d1f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java @@ -29,6 +29,8 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.TServerStatus; +import org.apache.accumulo.core.client.TableInfoUtil; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.ActiveCompaction; import org.apache.accumulo.core.client.admin.ActiveScan; @@ -38,6 +40,7 @@ import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.master.thrift.MasterClientService; import org.apache.accumulo.core.master.thrift.MasterMonitorInfo; +import org.apache.accumulo.core.master.thrift.TableInfo; import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.rpc.ThriftUtil; import org.apache.accumulo.core.tabletserver.thrift.TabletClientService; @@ -208,13 +211,14 @@ public void ping(String tserver) throws AccumuloException { } } } - + @Override - public String getTabletServerVersion(String tserver) throws AccumuloException { - String version = null; + public List getTabletServerStatus() throws AccumuloException { + List status = new ArrayList<>(); MasterMonitorInfo mmi = null; boolean retry = true; - + long now = System.currentTimeMillis(); + while (retry) { MasterClientService.Iface client = null; try { @@ -234,15 +238,34 @@ public String getTabletServerVersion(String tserver) throws AccumuloException { } } if (mmi != null) { - for (TabletServerStatus ts : mmi.getTServerInfo()) { - if (tserver.equals(ts.getName())) { - version = ts.getVersion(); - break; - } + for (TabletServerStatus ts : mmi.getTServerInfo()) { + + TableInfo summary = TableInfoUtil.summarizeTableStats(ts); + if (summary == null) + return status; + String name = ts.getName(); + int hostedTablets = summary.tablets; + long lastContact = now - ts.lastContact; + long entries = summary.recs; + double ingest = summary.ingestRate; + double query = summary.queryRate; + long holdTime = ts.holdTime; + Integer scans = summary.scans != null ? summary.scans.running : null; + Integer minor = summary.minors != null ? summary.minors.running : null; + Integer major = summary.majors != null ? summary.majors.running : null; + double indexHitRate = ts.indexCacheHits / (double) Math.max(ts.indexCacheRequest, 1); + double dataHitRate = ts.dataCacheHits / (double) Math.max(ts.dataCacheRequest, 1); + double osLoad = ts.osLoad; + String version = ts.version; + + TServerStatus stat = new TServerStatus(name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, + minor, major, indexHitRate, dataHitRate, osLoad, version); + + status.add(stat); } } - - return version; + + return status; } @Override diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java index a7622388b69..98bc9a957f2 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java @@ -20,9 +20,9 @@ import java.util.List; import java.util.Map; -import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.client.TServerStatus; import org.apache.accumulo.core.client.admin.ActiveCompaction; import org.apache.accumulo.core.client.admin.ActiveScan; import org.apache.accumulo.core.client.admin.InstanceOperations; @@ -97,7 +97,7 @@ public void ping(String tserver) throws AccumuloException { public void waitForBalance() throws AccumuloException {} @Override - public String getTabletServerVersion(String tserver) throws AccumuloException { - return Constants.VERSION; + public List getTabletServerStatus() throws AccumuloException { + return null; } } diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java index d302a5a9b17..d7974ff73a1 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java +++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java @@ -156,6 +156,7 @@ import org.apache.accumulo.shell.commands.TableCommand; import org.apache.accumulo.shell.commands.TablePermissionsCommand; import org.apache.accumulo.shell.commands.TablesCommand; +import org.apache.accumulo.shell.commands.TabletServerStatusCommand; import org.apache.accumulo.shell.commands.TraceCommand; import org.apache.accumulo.shell.commands.UserCommand; import org.apache.accumulo.shell.commands.UserPermissionsCommand; @@ -402,7 +403,7 @@ public void run() { Command[] dataCommands = {new DeleteCommand(), new DeleteManyCommand(), new DeleteRowsCommand(), new EGrepCommand(), new FormatterCommand(), new InterpreterCommand(), new GrepCommand(), new ImportDirectoryCommand(), new InsertCommand(), new MaxRowCommand(), new ScanCommand()}; Command[] debuggingCommands = {new ClasspathCommand(), new DebugCommand(), new ListScansCommand(), new ListCompactionsCommand(), new TraceCommand(), - new PingCommand(), new ListBulkCommand()}; + new PingCommand(), new ListBulkCommand(), new TabletServerStatusCommand()}; Command[] execCommands = {new ExecfileCommand(), new HistoryCommand(), new ExtensionCommand(), new ScriptCommand()}; Command[] exitCommands = {new ByeCommand(), new ExitCommand(), new QuitCommand()}; Command[] helpCommands = {new AboutCommand(), new HelpCommand(), new InfoCommand(), new QuestionCommand()}; diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java index 8d6159c5fdb..b164f2f9385 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java @@ -43,11 +43,11 @@ public String next() { try { instanceOps.ping(tserver); - return tserver + " OK " + instanceOps.getTabletServerVersion(tserver); } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } - + + return tserver + " OK"; } @Override diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java new file mode 100644 index 00000000000..98b93d9b464 --- /dev/null +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java @@ -0,0 +1,86 @@ +/* + * 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.accumulo.shell.commands; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.accumulo.core.client.TServerStatus; +import org.apache.accumulo.core.client.admin.InstanceOperations; +import org.apache.accumulo.shell.Shell; +import org.apache.accumulo.shell.Shell.Command; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; + +/** + * + */ +public class TabletServerStatusCommand extends Command { + + private Option tserverOption, disablePaginationOpt; + + @Override + public String description() { + return "get tablet servers status"; + } + + @Override + public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { + + List tservers; + + final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); + + final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt()); + + if (cl.hasOption(tserverOption.getOpt())) { + tservers = new ArrayList<>(); + for (TServerStatus ts : instanceOps.getTabletServerStatus()) { + if (ts.getName().equals(cl.getOptionValue(tserverOption.getOpt()))) { + tservers.add(ts); + } + } + } else { + tservers = instanceOps.getTabletServerStatus(); + } + + shellState.printLines(new TabletServerStatusIterator(tservers, instanceOps), paginate); + + return 0; + } + + @Override + public int numArgs() { + return 0; + } + + @Override + public Options getOptions() { + final Options opts = new Options(); + + tserverOption = new Option("ts", "tabletServer", true, "tablet server to find status"); + tserverOption.setArgName("tablet server"); + opts.addOption(tserverOption); + + disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); + opts.addOption(disablePaginationOpt); + + return opts; + } + +} diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java new file mode 100644 index 00000000000..152353e6019 --- /dev/null +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java @@ -0,0 +1,88 @@ +/* + * 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.accumulo.shell.commands; + +import java.util.Iterator; +import java.util.List; + +import org.apache.accumulo.core.client.TServerStatus; +import org.apache.accumulo.core.client.admin.InstanceOperations; + +class TabletServerStatusIterator implements Iterator { + + private Iterator iter; + private InstanceOperations instanceOps; + + TabletServerStatusIterator(List tservers, InstanceOperations instanceOps) { + iter = tservers.iterator(); + this.instanceOps = instanceOps; + } + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public String next() { + TServerStatus tserver = iter.next(); + long now = System.currentTimeMillis(); + String name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, dataHitRate, + osLoad, version; + + name = tserver.getName(); + hostedTablets = Integer.toString(tserver.getHostedTablets()); + lastContact = Long.toString(now - tserver.getLastContact()); + entries = Long.toString(tserver.getEntries()); + ingest = Double.toString(tserver.getIngest()); + query = Double.toString(tserver.getQuery()); + holdTime = Long.toString(tserver.getHoldTime()); + scans = Integer.toString(tserver.getScans()); + minor = Integer.toString(tserver.getMinor()); + major = Integer.toString(tserver.getMajor()); + indexHitRate = Double.toString(tserver.getIndexHitRate()); + dataHitRate = Double.toString(tserver.getDataHitRate()); + osLoad = Double.toString(tserver.getOsLoad()); + version = tserver.getVersion(); + + // Check config file for this + + return "\n-----------------------+------------------" + + "\nNAME | VALUE " + + "\n-----------------------+------------------" + + "\nServer ............... | " + name + + "\nHosted Tablets ....... | " + hostedTablets + + "\nLast Contact ......... |" + lastContact + + "\nEntries .............. | " + entries + + "\nIngest ............... | " + ingest + + "\nQuery ................ | " + query + + "\nHold Time ............ | " + holdTime + + "\nRunning Scans ........ | " + scans + + "\nMinor Compactions .... | " + minor + + "\nMajor Compactions .... | " + major + + "\nIndex Cache Hit Rate . | " + indexHitRate + + "\nData Cache Hit Rate .. | " + dataHitRate + + "\nOS Load .............. | " + osLoad + + "\nVersion .............. | " + version; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + +} From 7239486404268df156c0c7ff91f899fdba1574f6 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Mon, 9 Jan 2017 08:40:10 -0500 Subject: [PATCH 08/13] ACCUMULO-4558 Modified the output so that it is similar to the config command output --- .../accumulo/core/client/TServerStatus.java | 1 + .../commands/TabletServerStatusCommand.java | 21 +++-- .../commands/TabletServerStatusIterator.java | 77 ++++++++++++++----- 3 files changed, 73 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java index a50d31c7cfa..8aefb9d2c94 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java +++ b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java @@ -25,6 +25,7 @@ public class TServerStatus extends RuntimeException { + private static final long serialVersionUID = 1L; private String name, version; int hostedTablets; long lastContact, entries, holdTime; diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java index 98b93d9b464..460ea781d98 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java @@ -19,20 +19,24 @@ import java.util.ArrayList; import java.util.List; +import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.TServerStatus; import org.apache.accumulo.core.client.admin.InstanceOperations; import org.apache.accumulo.shell.Shell; import org.apache.accumulo.shell.Shell.Command; import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.MissingArgumentException; +import org.apache.commons.cli.MissingOptionException; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; +import org.apache.hadoop.yarn.webapp.NotFoundException; /** * */ public class TabletServerStatusCommand extends Command { - private Option tserverOption, disablePaginationOpt; + private Option tserverOption, disablePaginationOpt, allOption; @Override public String description() { @@ -40,8 +44,7 @@ public String description() { } @Override - public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { - + public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List tservers; final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); @@ -55,11 +58,16 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s tservers.add(ts); } } - } else { + } else if (cl.hasOption(allOption.getOpt())) { tservers = instanceOps.getTabletServerStatus(); + } else { + throw new MissingOptionException("Missing options"); } - shellState.printLines(new TabletServerStatusIterator(tservers, instanceOps), paginate); + if (tservers.isEmpty()) { + throw new NotFoundException("Tablet Servers not found"); + } + shellState.printLines(new TabletServerStatusIterator(tservers, shellState), paginate); return 0; } @@ -79,6 +87,9 @@ public Options getOptions() { disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); opts.addOption(disablePaginationOpt); + + allOption = new Option("a", "all", false, "list tablet servers status"); + opts.addOption(allOption); return opts; } diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java index 152353e6019..eb759eed24a 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java @@ -20,16 +20,19 @@ import java.util.List; import org.apache.accumulo.core.client.TServerStatus; -import org.apache.accumulo.core.client.admin.InstanceOperations; +import org.apache.accumulo.shell.Shell; + +import jline.console.ConsoleReader; class TabletServerStatusIterator implements Iterator { private Iterator iter; - private InstanceOperations instanceOps; + private int COL1 = 25; + private ConsoleReader reader; - TabletServerStatusIterator(List tservers, InstanceOperations instanceOps) { + TabletServerStatusIterator(List tservers, Shell shellState) { iter = tservers.iterator(); - this.instanceOps = instanceOps; + this.reader = shellState.getReader(); } @Override @@ -41,6 +44,7 @@ public boolean hasNext() { public String next() { TServerStatus tserver = iter.next(); long now = System.currentTimeMillis(); + String name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, dataHitRate, osLoad, version; @@ -61,28 +65,59 @@ public String next() { // Check config file for this - return "\n-----------------------+------------------" + - "\nNAME | VALUE " + - "\n-----------------------+------------------" + - "\nServer ............... | " + name + - "\nHosted Tablets ....... | " + hostedTablets + - "\nLast Contact ......... |" + lastContact + - "\nEntries .............. | " + entries + - "\nIngest ............... | " + ingest + - "\nQuery ................ | " + query + - "\nHold Time ............ | " + holdTime + - "\nRunning Scans ........ | " + scans + - "\nMinor Compactions .... | " + minor + - "\nMajor Compactions .... | " + major + - "\nIndex Cache Hit Rate . | " + indexHitRate + - "\nData Cache Hit Rate .. | " + dataHitRate + - "\nOS Load .............. | " + osLoad + - "\nVersion .............. | " + version; + String output = ""; + + output += printStatHeader(); + output += printStatLine("Server", name); + output += printStatLine("Hosted Tablets", hostedTablets); + output += printStatLine("Last Contact", lastContact); + output += printStatLine("Entries", entries); + output += printStatLine("Ingest", ingest); + output += printStatLine("Query", query); + output += printStatLine("Hold Time", holdTime); + output += printStatLine("Running Scans", scans); + output += printStatLine("Minor Compactions", minor); + output += printStatLine("Major Compactions", major); + output += printStatLine("Index Cache Hit Rate", indexHitRate); + output += printStatLine("Data Cache Hit Rate", dataHitRate); + output += printStatLine("OS Load", osLoad); + output += printStatLine("Version", version); + + output += printStatFooter(); + + return output; } @Override public void remove() { throw new UnsupportedOperationException(); } + + private String printStatHeader() { + String output = ""; + output += printStatFooter(); + output += (String.format("\n%-" + COL1 + "s | %s", "NAME", "VALUE")); + output += printStatFooter(); + + return output; + } + + private String printStatLine(String s1, String s2) { + String output = ""; + if (s1.length() < COL1) { + s1 += " " + Shell.repeat(".", COL1 - s1.length() - 1); + } + output += String.format("\n%-" + COL1 + "s | %s", s1, s2.replace("\n", "\n" + Shell.repeat(" ", COL1 + 1) + "| ")); + + return output; + } + + private String printStatFooter() { + String output = ""; + int col2 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - 6)); + output += String.format("\n%" + COL1 + "s-+-%-" + col2 + "s", Shell.repeat("-", COL1), Shell.repeat("-", col2)); + + return output; + } } From 5e9ac299af1ab1ad771e3d2b964287eb8f3cc7ab Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Mon, 9 Jan 2017 12:10:23 -0500 Subject: [PATCH 09/13] ACCUMULO-4558 Moved TableInfoUtil to util folder, fixed the imports to point to it --- .../accumulo/core/client/TServerStatus.java | 8 ++--- .../core/client/admin/InstanceOperations.java | 4 +-- .../client/impl/InstanceOperationsImpl.java | 20 ++++++------ .../core/{client => util}/TableInfoUtil.java | 2 +- .../accumulo/shell/commands/PingIterator.java | 2 +- .../commands/TabletServerStatusCommand.java | 8 ++--- .../commands/TabletServerStatusIterator.java | 31 +++++++++---------- 7 files changed, 35 insertions(+), 40 deletions(-) rename core/src/main/java/org/apache/accumulo/core/{client => util}/TableInfoUtil.java (98%) diff --git a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java index 8aefb9d2c94..7b90507e501 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java +++ b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java @@ -31,7 +31,7 @@ public class TServerStatus extends RuntimeException { long lastContact, entries, holdTime; double ingest, query, indexHitRate, dataHitRate, osLoad; Integer scans, minor, major; - + public TServerStatus() { name = ""; hostedTablets = 0; @@ -49,9 +49,8 @@ public TServerStatus() { version = ""; } - public TServerStatus(String name, int hostedTablets, long lastContact, long entries, double ingest, double query, - long holdTime, Integer scans, Integer minor, Integer major, double indexHitRate, double dataHitRate, double osLoad, - String version) { + public TServerStatus(String name, int hostedTablets, long lastContact, long entries, double ingest, double query, long holdTime, Integer scans, + Integer minor, Integer major, double indexHitRate, double dataHitRate, double osLoad, String version) { this.name = name; this.hostedTablets = hostedTablets; this.lastContact = lastContact; @@ -180,5 +179,4 @@ public void setMajor(Integer major) { this.major = major; } - } diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java index e7dd58d8fc3..88d453dc75e 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java @@ -80,13 +80,13 @@ public interface InstanceOperations { */ List getTabletServers(); - + /** * List the tablet server status * * @return A list of tablet server status. */ - + List getTabletServerStatus() throws AccumuloException; /** diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java index 3f43bb64d1f..c6023f3f860 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java @@ -30,7 +30,6 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.TServerStatus; -import org.apache.accumulo.core.client.TableInfoUtil; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.ActiveCompaction; import org.apache.accumulo.core.client.admin.ActiveScan; @@ -47,6 +46,7 @@ import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client; import org.apache.accumulo.core.trace.Tracer; import org.apache.accumulo.core.util.AddressUtil; +import org.apache.accumulo.core.util.TableInfoUtil; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.zookeeper.ZooCache; import org.apache.accumulo.fate.zookeeper.ZooCacheFactory; @@ -211,14 +211,14 @@ public void ping(String tserver) throws AccumuloException { } } } - + @Override public List getTabletServerStatus() throws AccumuloException { List status = new ArrayList<>(); MasterMonitorInfo mmi = null; boolean retry = true; long now = System.currentTimeMillis(); - + while (retry) { MasterClientService.Iface client = null; try { @@ -238,8 +238,8 @@ public List getTabletServerStatus() throws AccumuloException { } } if (mmi != null) { - for (TabletServerStatus ts : mmi.getTServerInfo()) { - + for (TabletServerStatus ts : mmi.getTServerInfo()) { + TableInfo summary = TableInfoUtil.summarizeTableStats(ts); if (summary == null) return status; @@ -257,14 +257,14 @@ public List getTabletServerStatus() throws AccumuloException { double dataHitRate = ts.dataCacheHits / (double) Math.max(ts.dataCacheRequest, 1); double osLoad = ts.osLoad; String version = ts.version; - - TServerStatus stat = new TServerStatus(name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, - minor, major, indexHitRate, dataHitRate, osLoad, version); - + + TServerStatus stat = new TServerStatus(name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, + dataHitRate, osLoad, version); + status.add(stat); } } - + return status; } diff --git a/core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java b/core/src/main/java/org/apache/accumulo/core/util/TableInfoUtil.java similarity index 98% rename from core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java rename to core/src/main/java/org/apache/accumulo/core/util/TableInfoUtil.java index eabc6701e62..a8916f1edd2 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/TableInfoUtil.java +++ b/core/src/main/java/org/apache/accumulo/core/util/TableInfoUtil.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.core.client; +package org.apache.accumulo.core.util; import java.util.HashMap; import java.util.Map; diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java index b164f2f9385..4072ec050b9 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java @@ -46,7 +46,7 @@ public String next() { } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } - + return tserver + " OK"; } diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java index 460ea781d98..a0f002d767a 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java @@ -19,13 +19,11 @@ import java.util.ArrayList; import java.util.List; -import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.TServerStatus; import org.apache.accumulo.core.client.admin.InstanceOperations; import org.apache.accumulo.shell.Shell; import org.apache.accumulo.shell.Shell.Command; import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.MissingArgumentException; import org.apache.commons.cli.MissingOptionException; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; @@ -44,7 +42,7 @@ public String description() { } @Override - public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { + public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { List tservers; final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); @@ -63,7 +61,7 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s } else { throw new MissingOptionException("Missing options"); } - + if (tservers.isEmpty()) { throw new NotFoundException("Tablet Servers not found"); } @@ -87,7 +85,7 @@ public Options getOptions() { disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output"); opts.addOption(disablePaginationOpt); - + allOption = new Option("a", "all", false, "list tablet servers status"); opts.addOption(allOption); diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java index eb759eed24a..dc48376248a 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java @@ -44,10 +44,9 @@ public boolean hasNext() { public String next() { TServerStatus tserver = iter.next(); long now = System.currentTimeMillis(); - - String name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, dataHitRate, - osLoad, version; - + + String name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, dataHitRate, osLoad, version; + name = tserver.getName(); hostedTablets = Integer.toString(tserver.getHostedTablets()); lastContact = Long.toString(now - tserver.getLastContact()); @@ -62,9 +61,9 @@ public String next() { dataHitRate = Double.toString(tserver.getDataHitRate()); osLoad = Double.toString(tserver.getOsLoad()); version = tserver.getVersion(); - + // Check config file for this - + String output = ""; output += printStatHeader(); @@ -82,9 +81,9 @@ public String next() { output += printStatLine("Data Cache Hit Rate", dataHitRate); output += printStatLine("OS Load", osLoad); output += printStatLine("Version", version); - + output += printStatFooter(); - + return output; } @@ -92,31 +91,31 @@ public String next() { public void remove() { throw new UnsupportedOperationException(); } - + private String printStatHeader() { String output = ""; output += printStatFooter(); output += (String.format("\n%-" + COL1 + "s | %s", "NAME", "VALUE")); output += printStatFooter(); - + return output; } - + private String printStatLine(String s1, String s2) { String output = ""; - if (s1.length() < COL1) { + if (s1.length() < COL1) { s1 += " " + Shell.repeat(".", COL1 - s1.length() - 1); } output += String.format("\n%-" + COL1 + "s | %s", s1, s2.replace("\n", "\n" + Shell.repeat(" ", COL1 + 1) + "| ")); - + return output; } - + private String printStatFooter() { String output = ""; - int col2 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - 6)); + int col2 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - 6)); output += String.format("\n%" + COL1 + "s-+-%-" + col2 + "s", Shell.repeat("-", COL1), Shell.repeat("-", col2)); - + return output; } From d9ab22a799d6189f70e3a30ca088b4fcb7b85488 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Wed, 11 Jan 2017 13:42:15 -0500 Subject: [PATCH 10/13] ACCUMULO-4558 Added tabletServerNotFoundException when looking for a server --- .../client/TabletServerNotFoundException.java | 70 +++++++++++++++++++ .../client/impl/InstanceOperationsImpl.java | 3 + .../commands/TabletServerStatusCommand.java | 6 +- 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java diff --git a/core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java b/core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java new file mode 100644 index 00000000000..34067c9e342 --- /dev/null +++ b/core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java @@ -0,0 +1,70 @@ +/* + * 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.accumulo.core.client; + +/** + * Thrown when the server specified doesn't exist when it was expected to + */ +public class TabletServerNotFoundException extends Exception { + /** + * Exception to throw if an operation is attempted on a namespace that doesn't exist. + * + */ + private static final long serialVersionUID = 1L; + + private String server; + + /** + * @param description + * the specific reason why it failed + */ + public TabletServerNotFoundException(String description) { + super(description != null && !description.isEmpty() ? description : ""); + } + + /** + * @param serverName + * the visible name of the server that was sought + * @param description + * the specific reason why it failed + */ + public TabletServerNotFoundException(String serverName, String description) { + super("Server" + (serverName != null && !serverName.isEmpty() ? " " + serverName : "") + " does not exist" + + (description != null && !description.isEmpty() ? description : "")); + this.server = serverName; + } + + /** + * @param serverName + * the visible name of the server that was sought + * @param description + * the specific reason why it failed + * @param cause + * the exception that caused this failure + */ + public TabletServerNotFoundException(String serverName, String description, Throwable cause) { + this(serverName, description); + super.initCause(cause); + } + + /** + * @return the name of the server sought + */ + public String getServerName() { + return server; + } +} diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java index c6023f3f860..013352c56ca 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java @@ -236,6 +236,9 @@ public List getTabletServerStatus() throws AccumuloException { MasterClient.close(client); } } + if (mmi == null) { + break; + } } if (mmi != null) { for (TabletServerStatus ts : mmi.getTServerInfo()) { diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java index a0f002d767a..7abf244bd1a 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java @@ -20,6 +20,7 @@ import java.util.List; import org.apache.accumulo.core.client.TServerStatus; +import org.apache.accumulo.core.client.TabletServerNotFoundException; import org.apache.accumulo.core.client.admin.InstanceOperations; import org.apache.accumulo.shell.Shell; import org.apache.accumulo.shell.Shell.Command; @@ -27,7 +28,6 @@ import org.apache.commons.cli.MissingOptionException; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; -import org.apache.hadoop.yarn.webapp.NotFoundException; /** * @@ -38,7 +38,7 @@ public class TabletServerStatusCommand extends Command { @Override public String description() { - return "get tablet servers status"; + return "get tablet servers status, master server must be running"; } @Override @@ -63,7 +63,7 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s } if (tservers.isEmpty()) { - throw new NotFoundException("Tablet Servers not found"); + throw new TabletServerNotFoundException("Tablet Servers not found"); } shellState.printLines(new TabletServerStatusIterator(tservers, shellState), paginate); From 3f5e686b8ff31ad4b29e93e3561b1b4d98585797 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Thu, 12 Jan 2017 07:59:32 -0500 Subject: [PATCH 11/13] ACCUMULO-4558 Removed RunTimeException, fixing checkstyle error --- .../java/org/apache/accumulo/core/client/TServerStatus.java | 3 +-- .../apache/accumulo/core/client/admin/InstanceOperations.java | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java index 7b90507e501..a6c09c1f250 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java +++ b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java @@ -23,9 +23,8 @@ * */ -public class TServerStatus extends RuntimeException { +public class TServerStatus { - private static final long serialVersionUID = 1L; private String name, version; int hostedTablets; long lastContact, entries, holdTime; diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java index 88d453dc75e..c78acc4fd7f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java @@ -83,8 +83,9 @@ public interface InstanceOperations { /** * List the tablet server status - * + * * @return A list of tablet server status. + * @since 2.0.0 */ List getTabletServerStatus() throws AccumuloException; From 7ef9304b78e5d78f6a52fc559c422bd1f49889e1 Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Thu, 12 Jan 2017 13:14:04 -0500 Subject: [PATCH 12/13] ACCUMULO-4558 Removed TServerStatus object and replaced it with a List of Map objects --- .../accumulo/core/client/TServerStatus.java | 181 ------------------ .../client/TabletServerNotFoundException.java | 70 ------- .../core/client/admin/InstanceOperations.java | 3 +- .../client/impl/InstanceOperationsImpl.java | 47 +++-- .../client/mock/MockInstanceOperations.java | 5 +- .../commands/TabletServerStatusCommand.java | 14 +- .../commands/TabletServerStatusIterator.java | 52 ++--- 7 files changed, 49 insertions(+), 323 deletions(-) delete mode 100644 core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java delete mode 100644 core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java diff --git a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java b/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java deleted file mode 100644 index a6c09c1f250..00000000000 --- a/core/src/main/java/org/apache/accumulo/core/client/TServerStatus.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.accumulo.core.client; - -/** - * This exception is thrown if a table is deleted after an operation starts. - * - * For example if table A exist when a scan is started, but is deleted during the scan then this exception is thrown. - * - */ - -public class TServerStatus { - - private String name, version; - int hostedTablets; - long lastContact, entries, holdTime; - double ingest, query, indexHitRate, dataHitRate, osLoad; - Integer scans, minor, major; - - public TServerStatus() { - name = ""; - hostedTablets = 0; - lastContact = 0l; - entries = 0l; - ingest = 0.0; - query = 0.0; - holdTime = 0l; - scans = null; - minor = null; - major = null; - indexHitRate = 0.0; - dataHitRate = 0.0; - osLoad = 0.0; - version = ""; - } - - public TServerStatus(String name, int hostedTablets, long lastContact, long entries, double ingest, double query, long holdTime, Integer scans, - Integer minor, Integer major, double indexHitRate, double dataHitRate, double osLoad, String version) { - this.name = name; - this.hostedTablets = hostedTablets; - this.lastContact = lastContact; - this.entries = entries; - this.ingest = ingest; - this.query = query; - this.holdTime = holdTime; - this.scans = scans; - this.minor = minor; - this.major = major; - this.indexHitRate = indexHitRate; - this.dataHitRate = dataHitRate; - this.osLoad = osLoad; - this.version = version; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public int getHostedTablets() { - return hostedTablets; - } - - public void setHostedTablets(int hostedTablets) { - this.hostedTablets = hostedTablets; - } - - public long getLastContact() { - return lastContact; - } - - public void setLastContact(long lastContact) { - this.lastContact = lastContact; - } - - public long getEntries() { - return entries; - } - - public void setEntries(long entries) { - this.entries = entries; - } - - public long getHoldTime() { - return holdTime; - } - - public void setHoldTime(long holdTime) { - this.holdTime = holdTime; - } - - public double getIngest() { - return ingest; - } - - public void setIngest(double ingest) { - this.ingest = ingest; - } - - public double getQuery() { - return query; - } - - public void setQuery(double query) { - this.query = query; - } - - public double getIndexHitRate() { - return indexHitRate; - } - - public void setIndexHitRate(double indexHitRate) { - this.indexHitRate = indexHitRate; - } - - public double getDataHitRate() { - return dataHitRate; - } - - public void setDataHitRate(double dataHitRate) { - this.dataHitRate = dataHitRate; - } - - public double getOsLoad() { - return osLoad; - } - - public void setOsLoad(double osLoad) { - this.osLoad = osLoad; - } - - public Integer getScans() { - return scans; - } - - public void setScans(Integer scans) { - this.scans = scans; - } - - public Integer getMinor() { - return minor; - } - - public void setMinor(Integer minor) { - this.minor = minor; - } - - public Integer getMajor() { - return major; - } - - public void setMajor(Integer major) { - this.major = major; - } - -} diff --git a/core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java b/core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java deleted file mode 100644 index 34067c9e342..00000000000 --- a/core/src/main/java/org/apache/accumulo/core/client/TabletServerNotFoundException.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.accumulo.core.client; - -/** - * Thrown when the server specified doesn't exist when it was expected to - */ -public class TabletServerNotFoundException extends Exception { - /** - * Exception to throw if an operation is attempted on a namespace that doesn't exist. - * - */ - private static final long serialVersionUID = 1L; - - private String server; - - /** - * @param description - * the specific reason why it failed - */ - public TabletServerNotFoundException(String description) { - super(description != null && !description.isEmpty() ? description : ""); - } - - /** - * @param serverName - * the visible name of the server that was sought - * @param description - * the specific reason why it failed - */ - public TabletServerNotFoundException(String serverName, String description) { - super("Server" + (serverName != null && !serverName.isEmpty() ? " " + serverName : "") + " does not exist" - + (description != null && !description.isEmpty() ? description : "")); - this.server = serverName; - } - - /** - * @param serverName - * the visible name of the server that was sought - * @param description - * the specific reason why it failed - * @param cause - * the exception that caused this failure - */ - public TabletServerNotFoundException(String serverName, String description, Throwable cause) { - this(serverName, description); - super.initCause(cause); - } - - /** - * @return the name of the server sought - */ - public String getServerName() { - return server; - } -} diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java index c78acc4fd7f..89b6197da32 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java @@ -21,7 +21,6 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.accumulo.core.client.TServerStatus; /** * @@ -88,7 +87,7 @@ public interface InstanceOperations { * @since 2.0.0 */ - List getTabletServerStatus() throws AccumuloException; + List> getTabletServerStatus() throws AccumuloException; /** * List the active scans on tablet server. diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java index 013352c56ca..c9f85cf3681 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/InstanceOperationsImpl.java @@ -23,13 +23,13 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.UUID; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Instance; -import org.apache.accumulo.core.client.TServerStatus; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.ActiveCompaction; import org.apache.accumulo.core.client.admin.ActiveScan; @@ -213,8 +213,8 @@ public void ping(String tserver) throws AccumuloException { } @Override - public List getTabletServerStatus() throws AccumuloException { - List status = new ArrayList<>(); + public List> getTabletServerStatus() throws AccumuloException { + List> status = new ArrayList<>(); MasterMonitorInfo mmi = null; boolean retry = true; long now = System.currentTimeMillis(); @@ -247,22 +247,35 @@ public List getTabletServerStatus() throws AccumuloException { if (summary == null) return status; String name = ts.getName(); - int hostedTablets = summary.tablets; - long lastContact = now - ts.lastContact; - long entries = summary.recs; - double ingest = summary.ingestRate; - double query = summary.queryRate; - long holdTime = ts.holdTime; - Integer scans = summary.scans != null ? summary.scans.running : null; - Integer minor = summary.minors != null ? summary.minors.running : null; - Integer major = summary.majors != null ? summary.majors.running : null; - double indexHitRate = ts.indexCacheHits / (double) Math.max(ts.indexCacheRequest, 1); - double dataHitRate = ts.dataCacheHits / (double) Math.max(ts.dataCacheRequest, 1); - double osLoad = ts.osLoad; + String tablets = Integer.toString(summary.tablets); + String lastContact = Long.toString(now - ts.lastContact); + String entries = Long.toString(summary.recs); + String ingest = Double.toString(summary.ingestRate); + String query = Double.toString(summary.queryRate); + String holdTime = Long.toString(ts.holdTime); + String scans = summary.scans != null ? Integer.toString(summary.scans.running) : null; + String minor = summary.minors != null ? Integer.toString(summary.minors.running) : null; + String major = summary.majors != null ? Integer.toString(summary.majors.running) : null; + String indexHitRate = Double.toString(ts.indexCacheHits / (double) Math.max(ts.indexCacheRequest, 1)); + String dataHitRate = Double.toString(ts.dataCacheHits / (double) Math.max(ts.dataCacheRequest, 1)); + String osLoad = Double.toString(ts.osLoad); String version = ts.version; - TServerStatus stat = new TServerStatus(name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, - dataHitRate, osLoad, version); + Map stat = new TreeMap(); + stat.put("server", name); + stat.put("tablets", tablets); + stat.put("lastContact", lastContact); + stat.put("entries", entries); + stat.put("ingest", ingest); + stat.put("query", query); + stat.put("holdtime", holdTime); + stat.put("scans", scans); + stat.put("minor", minor); + stat.put("major", major); + stat.put("indexCacheHitRate", indexHitRate); + stat.put("dataCacheHitRate", dataHitRate); + stat.put("osload", osLoad); + stat.put("version", version); status.add(stat); } diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java index 98bc9a957f2..ee30456d369 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockInstanceOperations.java @@ -22,7 +22,6 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.accumulo.core.client.TServerStatus; import org.apache.accumulo.core.client.admin.ActiveCompaction; import org.apache.accumulo.core.client.admin.ActiveScan; import org.apache.accumulo.core.client.admin.InstanceOperations; @@ -97,7 +96,7 @@ public void ping(String tserver) throws AccumuloException { public void waitForBalance() throws AccumuloException {} @Override - public List getTabletServerStatus() throws AccumuloException { - return null; + public List> getTabletServerStatus() throws AccumuloException { + return new ArrayList<>(); } } diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java index 7abf244bd1a..e8494ef671b 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusCommand.java @@ -18,9 +18,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; -import org.apache.accumulo.core.client.TServerStatus; -import org.apache.accumulo.core.client.TabletServerNotFoundException; import org.apache.accumulo.core.client.admin.InstanceOperations; import org.apache.accumulo.shell.Shell; import org.apache.accumulo.shell.Shell.Command; @@ -38,12 +37,12 @@ public class TabletServerStatusCommand extends Command { @Override public String description() { - return "get tablet servers status, master server must be running"; + return "get tablet servers status"; } @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { - List tservers; + List> tservers; final InstanceOperations instanceOps = shellState.getConnector().instanceOperations(); @@ -51,8 +50,8 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s if (cl.hasOption(tserverOption.getOpt())) { tservers = new ArrayList<>(); - for (TServerStatus ts : instanceOps.getTabletServerStatus()) { - if (ts.getName().equals(cl.getOptionValue(tserverOption.getOpt()))) { + for (Map ts : instanceOps.getTabletServerStatus()) { + if (ts.get("server").equals(cl.getOptionValue(tserverOption.getOpt()))) { tservers.add(ts); } } @@ -62,9 +61,6 @@ public int execute(final String fullCommand, final CommandLine cl, final Shell s throw new MissingOptionException("Missing options"); } - if (tservers.isEmpty()) { - throw new TabletServerNotFoundException("Tablet Servers not found"); - } shellState.printLines(new TabletServerStatusIterator(tservers, shellState), paginate); return 0; diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java index dc48376248a..a29d441d707 100644 --- a/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java +++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TabletServerStatusIterator.java @@ -18,19 +18,19 @@ import java.util.Iterator; import java.util.List; +import java.util.Map; -import org.apache.accumulo.core.client.TServerStatus; import org.apache.accumulo.shell.Shell; import jline.console.ConsoleReader; class TabletServerStatusIterator implements Iterator { - private Iterator iter; + private Iterator> iter; private int COL1 = 25; private ConsoleReader reader; - TabletServerStatusIterator(List tservers, Shell shellState) { + TabletServerStatusIterator(List> tservers, Shell shellState) { iter = tservers.iterator(); this.reader = shellState.getReader(); } @@ -42,47 +42,17 @@ public boolean hasNext() { @Override public String next() { - TServerStatus tserver = iter.next(); - long now = System.currentTimeMillis(); - - String name, hostedTablets, lastContact, entries, ingest, query, holdTime, scans, minor, major, indexHitRate, dataHitRate, osLoad, version; - - name = tserver.getName(); - hostedTablets = Integer.toString(tserver.getHostedTablets()); - lastContact = Long.toString(now - tserver.getLastContact()); - entries = Long.toString(tserver.getEntries()); - ingest = Double.toString(tserver.getIngest()); - query = Double.toString(tserver.getQuery()); - holdTime = Long.toString(tserver.getHoldTime()); - scans = Integer.toString(tserver.getScans()); - minor = Integer.toString(tserver.getMinor()); - major = Integer.toString(tserver.getMajor()); - indexHitRate = Double.toString(tserver.getIndexHitRate()); - dataHitRate = Double.toString(tserver.getDataHitRate()); - osLoad = Double.toString(tserver.getOsLoad()); - version = tserver.getVersion(); - - // Check config file for this + Map tserver = iter.next(); String output = ""; output += printStatHeader(); - output += printStatLine("Server", name); - output += printStatLine("Hosted Tablets", hostedTablets); - output += printStatLine("Last Contact", lastContact); - output += printStatLine("Entries", entries); - output += printStatLine("Ingest", ingest); - output += printStatLine("Query", query); - output += printStatLine("Hold Time", holdTime); - output += printStatLine("Running Scans", scans); - output += printStatLine("Minor Compactions", minor); - output += printStatLine("Major Compactions", major); - output += printStatLine("Index Cache Hit Rate", indexHitRate); - output += printStatLine("Data Cache Hit Rate", dataHitRate); - output += printStatLine("OS Load", osLoad); - output += printStatLine("Version", version); - output += printStatFooter(); + for (Map.Entry entry : tserver.entrySet()) { + output += printStatLine(entry.getKey(), entry.getValue()); + } + + output += "\n" + printStatFooter(); return output; } @@ -95,7 +65,7 @@ public void remove() { private String printStatHeader() { String output = ""; output += printStatFooter(); - output += (String.format("\n%-" + COL1 + "s | %s", "NAME", "VALUE")); + output += (String.format("\n%-" + COL1 + "s | %s\n", "NAME", "VALUE")); output += printStatFooter(); return output; @@ -114,7 +84,7 @@ private String printStatLine(String s1, String s2) { private String printStatFooter() { String output = ""; int col2 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - 6)); - output += String.format("\n%" + COL1 + "s-+-%-" + col2 + "s", Shell.repeat("-", COL1), Shell.repeat("-", col2)); + output += String.format("%" + COL1 + "s-+-%-" + col2 + "s", Shell.repeat("-", COL1), Shell.repeat("-", col2)); return output; } From 77a8a79c1a2536cf795a1d2b60ace2bf005746fb Mon Sep 17 00:00:00 2001 From: Luis Tavarez Date: Thu, 6 Apr 2017 14:47:11 -0400 Subject: [PATCH 13/13] ACCUMULO-4558 Recompiled thrift --- .../master/thrift/TabletServerStatus.java | 177 ++++++------------ .../apache/accumulo/tserver/TabletServer.java | 1 - 2 files changed, 56 insertions(+), 122 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java b/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java index d7131db41f8..3406a03d5c5 100644 --- a/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java +++ b/core/src/main/java/org/apache/accumulo/core/master/thrift/TabletServerStatus.java @@ -22,33 +22,6 @@ */ package org.apache.accumulo.core.master.thrift; -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)") public class TabletServerStatus implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { @@ -70,11 +43,8 @@ public class TabletServerStatus implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new TabletServerStatusStandardSchemeFactory()); - schemes.put(TupleScheme.class, new TabletServerStatusTupleSchemeFactory()); - } + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TabletServerStatusStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TabletServerStatusTupleSchemeFactory(); public java.util.Map tableMap; // required public long lastContact; // required @@ -89,8 +59,8 @@ public class TabletServerStatus implements org.apache.thrift.TBase logSorts; // required public long flushs; // required public long syncs; // required - public List bulkImports; // required - public String version; // required + public java.util.List bulkImports; // required + public java.lang.String version; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -241,7 +211,7 @@ public java.lang.String getFieldName() { new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, BulkImportStatus.class)))); tmpMap.put(_Fields.VERSION, new org.apache.thrift.meta_data.FieldMetaData("version", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TabletServerStatus.class, metaDataMap); } @@ -262,8 +232,8 @@ public TabletServerStatus( java.util.List logSorts, long flushs, long syncs, - List bulkImports, - String version) + java.util.List bulkImports, + java.lang.String version) { this(); this.tableMap = tableMap; @@ -745,11 +715,11 @@ public void setBulkImportsIsSet(boolean value) { } } - public String getVersion() { + public java.lang.String getVersion() { return this.version; } - public TabletServerStatus setVersion(String version) { + public TabletServerStatus setVersion(java.lang.String version) { this.version = version; return this; } @@ -887,7 +857,7 @@ public void setFieldValue(_Fields field, java.lang.Object value) { if (value == null) { unsetVersion(); } else { - setVersion((String)value); + setVersion((java.lang.String)value); } break; @@ -1141,84 +1111,49 @@ public boolean equals(TabletServerStatus that) { @Override public int hashCode() { - List list = new ArrayList(); - - boolean present_tableMap = true && (isSetTableMap()); - list.add(present_tableMap); - if (present_tableMap) - list.add(tableMap); - - boolean present_lastContact = true; - list.add(present_lastContact); - if (present_lastContact) - list.add(lastContact); - - boolean present_name = true && (isSetName()); - list.add(present_name); - if (present_name) - list.add(name); - - boolean present_osLoad = true; - list.add(present_osLoad); - if (present_osLoad) - list.add(osLoad); - - boolean present_holdTime = true; - list.add(present_holdTime); - if (present_holdTime) - list.add(holdTime); - - boolean present_lookups = true; - list.add(present_lookups); - if (present_lookups) - list.add(lookups); - - boolean present_indexCacheHits = true; - list.add(present_indexCacheHits); - if (present_indexCacheHits) - list.add(indexCacheHits); - - boolean present_indexCacheRequest = true; - list.add(present_indexCacheRequest); - if (present_indexCacheRequest) - list.add(indexCacheRequest); - - boolean present_dataCacheHits = true; - list.add(present_dataCacheHits); - if (present_dataCacheHits) - list.add(dataCacheHits); - - boolean present_dataCacheRequest = true; - list.add(present_dataCacheRequest); - if (present_dataCacheRequest) - list.add(dataCacheRequest); - - boolean present_logSorts = true && (isSetLogSorts()); - list.add(present_logSorts); - if (present_logSorts) - list.add(logSorts); - - boolean present_flushs = true; - list.add(present_flushs); - if (present_flushs) - list.add(flushs); - - boolean present_syncs = true; - list.add(present_syncs); - if (present_syncs) - list.add(syncs); - - boolean present_bulkImports = true && (isSetBulkImports()); - list.add(present_bulkImports); - if (present_bulkImports) - list.add(bulkImports); - - boolean present_version = true && (isSetVersion()); - list.add(present_version); - if (present_version) - list.add(version); - - return list.hashCode(); + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetTableMap()) ? 131071 : 524287); + if (isSetTableMap()) + hashCode = hashCode * 8191 + tableMap.hashCode(); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(lastContact); + + hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287); + if (isSetName()) + hashCode = hashCode * 8191 + name.hashCode(); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(osLoad); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(holdTime); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(lookups); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(indexCacheHits); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(indexCacheRequest); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(dataCacheHits); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(dataCacheRequest); + + hashCode = hashCode * 8191 + ((isSetLogSorts()) ? 131071 : 524287); + if (isSetLogSorts()) + hashCode = hashCode * 8191 + logSorts.hashCode(); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(flushs); + + hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(syncs); + + hashCode = hashCode * 8191 + ((isSetBulkImports()) ? 131071 : 524287); + if (isSetBulkImports()) + hashCode = hashCode * 8191 + bulkImports.hashCode(); + + hashCode = hashCode * 8191 + ((isSetVersion()) ? 131071 : 524287); + if (isSetVersion()) + hashCode = hashCode * 8191 + version.hashCode(); + + return hashCode; } @Override @@ -1369,7 +1304,7 @@ public int compareTo(TabletServerStatus other) { return lastComparison; } } - lastComparison = Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); + lastComparison = java.lang.Boolean.valueOf(isSetVersion()).compareTo(other.isSetVersion()); if (lastComparison != 0) { return lastComparison; } @@ -1902,8 +1837,8 @@ public void write(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus @Override public void read(org.apache.thrift.protocol.TProtocol prot, TabletServerStatus struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(15); + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(15); if (incoming.get(0)) { { org.apache.thrift.protocol.TMap _map16 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java index 8a0a4ef15c1..d83481a005b 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java @@ -347,7 +347,6 @@ public Metrics getMinCMetrics() { public TabletServer(Instance instance, ServerConfigurationFactory confFactory, VolumeManager fs) throws IOException { super(instance, confFactory); - this.version = Constants.VERSION; this.confFactory = confFactory; this.fs = fs; final AccumuloConfiguration aconf = getConfiguration();