diff options
author | Aditya Kishore <aditya@maprtech.com> | 2014-09-11 10:43:08 -0700 |
---|---|---|
committer | Aditya Kishore <aditya@maprtech.com> | 2014-09-11 19:25:28 -0700 |
commit | 676f5df6b14b10ccc3603360e0efee9c745c5b97 (patch) | |
tree | 592b02f84e8a6da2ace67f8e6c0e46d4237af20b /exec/java-exec/src/main/java/org/apache/drill/exec/coord | |
parent | 7ae257c42b2eb4e1db778dca9ba64e2516078b38 (diff) |
DRILL-1402: Add check-style rules for trailing space, TABs and blocks without braces
Diffstat (limited to 'exec/java-exec/src/main/java/org/apache/drill/exec/coord')
2 files changed, 35 insertions, 20 deletions
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/coord/local/LocalClusterCoordinator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/coord/local/LocalClusterCoordinator.java index 2ddf280e5..035c1aa2c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/coord/local/LocalClusterCoordinator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/coord/local/LocalClusterCoordinator.java @@ -31,7 +31,7 @@ import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; import com.google.common.collect.Maps; -public class LocalClusterCoordinator extends ClusterCoordinator{ +public class LocalClusterCoordinator extends ClusterCoordinator { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(LocalClusterCoordinator.class); private volatile Map<RegistrationHandle, DrillbitEndpoint> endpoints = Maps.newConcurrentMap(); @@ -57,7 +57,9 @@ public class LocalClusterCoordinator extends ClusterCoordinator{ @Override public void unregister(RegistrationHandle handle) { - if(handle == null) return; + if(handle == null) { + return; + } endpoints.remove(handle); } @@ -67,7 +69,6 @@ public class LocalClusterCoordinator extends ClusterCoordinator{ return endpoints.values(); } - private class Handle implements RegistrationHandle{ UUID id = UUID.randomUUID(); @@ -82,14 +83,26 @@ public class LocalClusterCoordinator extends ClusterCoordinator{ @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; + } Handle other = (Handle) obj; - if (!getOuterType().equals(other.getOuterType())) return false; + if (!getOuterType().equals(other.getOuterType())) { + return false; + } if (id == null) { - if (other.id != null) return false; - } else if (!id.equals(other.id)) return false; + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } return true; } @@ -99,7 +112,6 @@ public class LocalClusterCoordinator extends ClusterCoordinator{ } - @Override public DistributedSemaphore getSemaphore(String name, int maximumLeases) { semaphores.putIfAbsent(name, new LocalSemaphore(maximumLeases)); @@ -111,20 +123,19 @@ public class LocalClusterCoordinator extends ClusterCoordinator{ private final Semaphore inner; private final LocalLease lease = new LocalLease(); - public LocalSemaphore(int size){ + public LocalSemaphore(int size) { inner = new Semaphore(size); } @Override public DistributedLease acquire(long timeout, TimeUnit unit) throws Exception { - if(!inner.tryAcquire(timeout, unit)){ + if(!inner.tryAcquire(timeout, unit)) { return null; }else{ return lease; } } - private class LocalLease implements DistributedLease{ @Override @@ -135,5 +146,4 @@ public class LocalClusterCoordinator extends ClusterCoordinator{ } } - } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java index 76ad90b5f..7f538d2cd 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/coord/zk/ZKClusterCoordinator.java @@ -75,7 +75,7 @@ public class ZKClusterCoordinator extends ClusterCoordinator { // check if this is a complex zk string. If so, parse into components. Matcher m = ZK_COMPLEX_STRING.matcher(connect); - if(m.matches()){ + if(m.matches()) { connect = m.group(1); zkRoot = m.group(2); clusterId = m.group(3); @@ -101,7 +101,7 @@ public class ZKClusterCoordinator extends ClusterCoordinator { .build(); } - public CuratorFramework getCurator(){ + public CuratorFramework getCurator() { return curator; } @@ -112,9 +112,11 @@ public class ZKClusterCoordinator extends ClusterCoordinator { serviceCache.start(); serviceCache.addListener(new ZKListener()); - if(millisToWait != 0){ + if(millisToWait != 0) { boolean success = this.initialConnection.await(millisToWait, TimeUnit.MILLISECONDS); - if(!success) throw new IOException(String.format("Failure to connect to the zookeeper cluster service within the allotted time of %d milliseconds.", millisToWait)); + if (!success) { + throw new IOException(String.format("Failure to connect to the zookeeper cluster service within the allotted time of %d milliseconds.", millisToWait)); + } }else{ this.initialConnection.await(); } @@ -126,7 +128,7 @@ public class ZKClusterCoordinator extends ClusterCoordinator { @Override public void stateChanged(CuratorFramework client, ConnectionState newState) { - if(newState == ConnectionState.CONNECTED){ + if(newState == ConnectionState.CONNECTED) { ZKClusterCoordinator.this.initialConnection.countDown(); client.getConnectionStateListenable().removeListener(this); } @@ -166,7 +168,9 @@ public class ZKClusterCoordinator extends ClusterCoordinator { @Override public void unregister(RegistrationHandle handle) { - if (!(handle instanceof ZKRegistrationHandle)) throw new UnsupportedOperationException("Unknown handle type: " + handle.getClass().getName()); + if (!(handle instanceof ZKRegistrationHandle)) { + throw new UnsupportedOperationException("Unknown handle type: " + handle.getClass().getName()); + } ZKRegistrationHandle h = (ZKRegistrationHandle) handle; try { @@ -223,4 +227,5 @@ public class ZKClusterCoordinator extends ClusterCoordinator { .serializer(DrillServiceInstanceHelper.SERIALIZER) .build(); } + } |