Skip to content

Commit

Permalink
HBASE-19471 Fixed remaining Checkstyle errors in hbase-thrift
Browse files Browse the repository at this point in the history
  • Loading branch information
HorizonNet committed Jan 7, 2018
1 parent 228d7a5 commit 8301796
Show file tree
Hide file tree
Showing 17 changed files with 740 additions and 668 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
<suppress checks="MagicNumberCheck" files=".*/src/test/.*\.java"/>
<suppress checks="VisibilityModifier" files=".*/src/test/.*\.java"/>
<suppress checks="InterfaceIsTypeCheck" files=".*/src/main/.*\.java"/>
<suppress checks="EmptyBlockCheck" files="TBoundedThreadPoolServer.java"/>
</suppressions>
16 changes: 16 additions & 0 deletions hbase-thrift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* time of each call to ThriftMetrics.
*/
@InterfaceAudience.Private
public class HbaseHandlerMetricsProxy implements InvocationHandler {
public final class HbaseHandlerMetricsProxy implements InvocationHandler {

private static final Logger LOG = LoggerFactory.getLogger(
HbaseHandlerMetricsProxy.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,30 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}

FullyQualifiedRow other = (FullyQualifiedRow) obj;
if (!Arrays.equals(family, other.family)) return false;
if (!Arrays.equals(qualifier, other.qualifier)) return false;
if (!Arrays.equals(rowKey, other.rowKey)) return false;
if (!Arrays.equals(table, other.table)) return false;

if (!Arrays.equals(family, other.family)) {
return false;
}
if (!Arrays.equals(qualifier, other.qualifier)) {
return false;
}
if (!Arrays.equals(rowKey, other.rowKey)) {
return false;
}
if (!Arrays.equals(table, other.table)) {
return false;
}
return true;
}

Expand All @@ -144,8 +160,14 @@ static class DaemonThreadFactory implements ThreadFactory {

public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
if (!t.isDaemon()) t.setDaemon(true);
if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY);

if (!t.isDaemon()) {
t.setDaemon(true);
}
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}

return t;
}
}
Expand Down Expand Up @@ -191,13 +213,16 @@ public boolean queueIncrements(List<TIncrement> incs) throws TException {
for (TIncrement tinc : incs) {
internalQueueTincrement(tinc);
}
return true;

return true;
}

private boolean internalQueueTincrement(TIncrement inc) throws TException {
byte[][] famAndQf = CellUtil.parseColumn(inc.getColumn());
if (famAndQf.length != 2) return false;

if (famAndQf.length != 2) {
return false;
}

return internalQueueIncrement(inc.getTable(), inc.getRow(), famAndQf[0], famAndQf[1],
inc.getAmmount());
Expand All @@ -207,7 +232,6 @@ private boolean internalQueueIncrement(byte[] tableName, byte[] rowKey, byte[] f
byte[] qual, long ammount) throws TException {
int countersMapSize = countersMap.size();


//Make sure that the number of threads is scaled.
dynamicallySetCoreSize(countersMapSize);

Expand Down Expand Up @@ -293,7 +317,7 @@ public Integer call() throws Exception {
/**
* This method samples the incoming requests and, if selected, will check if
* the corePoolSize should be changed.
* @param countersMapSize
* @param countersMapSize the size of the counters map
*/
private void dynamicallySetCoreSize(int countersMapSize) {
// Here we are using countersMapSize as a random number, meaning this
Expand All @@ -302,9 +326,10 @@ private void dynamicallySetCoreSize(int countersMapSize) {
return;
}
double currentRatio = (double) countersMapSize / (double) maxQueueSize;
int newValue = 1;
int newValue;

if (currentRatio < 0.1) {
// it's 1
newValue = 1;
} else if (currentRatio < 0.3) {
newValue = 2;
} else if (currentRatio < 0.5) {
Expand All @@ -316,6 +341,7 @@ private void dynamicallySetCoreSize(int countersMapSize) {
} else {
newValue = 22;
}

if (pool.getCorePoolSize() != newValue) {
pool.setCorePoolSize(newValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void stop() {
serverTransport_.interrupt();
}

private class ClientConnnection implements Runnable {
private final class ClientConnnection implements Runnable {

private TTransport client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ public void setSource(MetricsThriftServerSource source) {


public ThriftMetrics(Configuration conf, ThriftServerType t) {
slowResponseTime = conf.getLong( SLOW_RESPONSE_NANO_SEC, DEFAULT_SLOW_RESPONSE_NANO_SEC);
slowResponseTime = conf.getLong(SLOW_RESPONSE_NANO_SEC, DEFAULT_SLOW_RESPONSE_NANO_SEC);

if (t == ThriftServerType.ONE) {
source = CompatibilitySingletonFactory.getInstance(MetricsThriftServerSourceFactory.class).createThriftOneSource();
source = CompatibilitySingletonFactory.getInstance(MetricsThriftServerSourceFactory.class)
.createThriftOneSource();
} else if (t == ThriftServerType.TWO) {
source = CompatibilitySingletonFactory.getInstance(MetricsThriftServerSourceFactory.class).createThriftTwoSource();
source = CompatibilitySingletonFactory.getInstance(MetricsThriftServerSourceFactory.class)
.createThriftTwoSource();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,24 @@ private static void printUsageAndExit(Options options, int exitCode)

/**
* Start up or shuts down the Thrift server, depending on the arguments.
* @param args
* @param args the arguments to pass in when starting the Thrift server
*/
void doMain(final String[] args) throws Exception {
processOptions(args);

serverRunner = new ThriftServerRunner(conf);

// Put up info server.
int port = conf.getInt("hbase.thrift.info.port", 9095);
if (port >= 0) {
conf.setLong("startcode", System.currentTimeMillis());
String a = conf.get("hbase.thrift.info.bindAddress", "0.0.0.0");
infoServer = new InfoServer("thrift", a, port, false, conf);
infoServer.setAttribute("hbase.conf", conf);
infoServer.start();
}
serverRunner.run();
void doMain(final String[] args) throws Exception {
processOptions(args);
serverRunner = new ThriftServerRunner(conf);

// Put up info server.
int port = conf.getInt("hbase.thrift.info.port", 9095);

if (port >= 0) {
conf.setLong("startcode", System.currentTimeMillis());
String a = conf.get("hbase.thrift.info.bindAddress", "0.0.0.0");
infoServer = new InfoServer("thrift", a, port, false, conf);
infoServer.setAttribute("hbase.conf", conf);
infoServer.start();
}

serverRunner.run();
}

/**
Expand Down Expand Up @@ -230,10 +231,6 @@ private static void optionToConf(CommandLine cmd, String option,
}
}

/**
* @param args
* @throws Exception
*/
public static void main(String [] args) throws Exception {
LOG.info("***** STARTING service '" + ThriftServer.class.getSimpleName() + "' *****");
VersionInfo.logVersion();
Expand Down
Loading

0 comments on commit 8301796

Please sign in to comment.