Code tidy a wider set of code.

This commit is contained in:
Peter Lawrey
2015-06-21 12:25:59 +01:00
parent 680182b129
commit 34c4cd8d32
32 changed files with 76 additions and 93 deletions
@@ -33,7 +33,7 @@ public final class ChronicleHashErrorListeners {
* We can add some configuration-on-the-first-call in the future.
*/
private static enum LoggingErrorListener implements ChronicleHashErrorListener {
private enum LoggingErrorListener implements ChronicleHashErrorListener {
INSTANCE;
@Override
@@ -52,7 +52,7 @@ public final class ChronicleHashErrorListeners {
}
}
private static enum ThrowingErrorListener implements ChronicleHashErrorListener {
private enum ThrowingErrorListener implements ChronicleHashErrorListener {
INSTANCE;
@Override
@@ -176,11 +176,9 @@ public final class TcpTransportAndNetworkConfig implements Serializable {
if (endpoints != null ? !endpoints.equals(that.endpoints) : that.endpoints != null)
return false;
if (heartBeatIntervalUnit != that.heartBeatIntervalUnit) return false;
if (throttlingConfig != null ? !throttlingConfig.equals(that.throttlingConfig) :
that.throttlingConfig != null)
return false;
return !(throttlingConfig != null ? !throttlingConfig.equals(that.throttlingConfig) :
that.throttlingConfig != null);
return true;
}
@Override
@@ -25,7 +25,7 @@ interface HashSplitting extends Serializable {
int segmentIndex(long hash);
long segmentHash(long hash);
static class Splitting {
class Splitting {
static HashSplitting forSegments(int segments) {
assert segments > 0;
if (segments == 1)
@@ -50,7 +50,7 @@ interface HashSplitting extends Serializable {
}
}
static class ForPowerOf2Segments implements HashSplitting {
class ForPowerOf2Segments implements HashSplitting {
private static final long serialVersionUID = 0L;
private final int mask;
@@ -73,7 +73,7 @@ interface HashSplitting extends Serializable {
}
//TODO optimize?
static class ForNonPowerOf2Segments implements HashSplitting {
class ForNonPowerOf2Segments implements HashSplitting {
private static final long serialVersionUID = 0L;
private static final int MASK = Integer.MAX_VALUE;
@@ -73,7 +73,7 @@ interface MultiMap {
void forEach(EntryConsumer action);
static interface EntryConsumer {
interface EntryConsumer {
void accept(long key, long value);
}
}
@@ -610,9 +610,8 @@ class AddressAndPort implements Comparable<AddressAndPort>, BytesMarshallable {
AddressAndPort that = (AddressAndPort) o;
if (port != that.port) return false;
if (!Arrays.equals(address, that.address)) return false;
return Arrays.equals(address, that.address);
return true;
}
@Override
@@ -890,9 +889,8 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable {
ProposedNodes that = (ProposedNodes) o;
if (identifier != that.identifier) return false;
if (!addressAndPort.equals(that.addressAndPort)) return false;
return addressAndPort.equals(that.addressAndPort);
return true;
}
@Override
@@ -270,7 +270,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
Object remoteRemove(K key,
final byte remoteIdentifier, long timeStamp) {
checkKey(key);
K key1 = (K) key;
K key1 = key;
ThreadLocalCopies copies = SegmentState.getCopies(null);
SegmentState segmentState = SegmentState.get(copies);
KI keyInterop = keyInteropProvider.get(copies, originalKeyInterop);
@@ -284,7 +284,7 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
segment.writeLock();
try {
return segment.removeWithoutLock(copies, segmentState, metaKeyInterop, keyInterop, key1,
keySize, keyIdentity(), this, (V) null, valueIdentity(), segmentHash, this,
keySize, keyIdentity(), this, null, valueIdentity(), segmentHash, this,
removeReturnsNull, timeStamp, remoteIdentifier, true, false);
} finally {
segment.writeUnlock();
@@ -98,7 +98,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
}
};
static enum EventId {
enum EventId {
HEARTBEAT,
STATEFUL_UPDATE,
LONG_SIZE,
@@ -551,7 +551,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
final long sizeLocation = writeEventAnSkip(GET);
copies = writeKey((K) key);
copies = writeKey(key);
transactionId = send(sizeLocation, startTime);
} finally {
outBytesLock.unlock();
@@ -560,7 +560,7 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
if (eventReturnsNull(GET))
return null;
return (V) readValue(transactionId, startTime, copies, usingValue);
return readValue(transactionId, startTime, copies, usingValue);
}
@@ -745,7 +745,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
"instance in the usual way.", e);
try {
return (T) aClass.newInstance();
return aClass.newInstance();
} catch (Exception e1) {
throw new IllegalStateException("It has not been possible to create a instance " +
"of class=" + aClass.getSimpleName() +
@@ -1022,7 +1022,7 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
@Override
public DelegatingMetaBytesInterop<Bytes, BytesInterop<Bytes>> getMetaValueInterop(
@NotNull ThreadLocalCopies copies, BytesInterop<Bytes> valueInterop, Bytes value) {
return DelegatingMetaBytesInterop.<Bytes, BytesInterop<Bytes>>instance();
return DelegatingMetaBytesInterop.instance();
}
@Override
@@ -113,5 +113,5 @@ interface BufferResizer {
* @param newCapacity
* @return the newly resize buffer
*/
public Bytes resizeBuffer(int newCapacity);
Bytes resizeBuffer(int newCapacity);
}
@@ -21,5 +21,5 @@ import net.openhft.chronicle.hash.ChronicleHash;
import java.util.Set;
public interface ChronicleSet<E> extends Set<E>, ChronicleHash {
public long longSize();
long longSize();
}
+13 -15
View File
@@ -24,38 +24,36 @@ import net.openhft.lang.model.constraints.MaxSize;
public interface TestInstrumentVOInterface {
public int getSizeOfInstrumentIDArray();
int getSizeOfInstrumentIDArray();
public void setSizeOfInstrumentIDArray(int sizeOfInstrumentIDArray);
void setSizeOfInstrumentIDArray(int sizeOfInstrumentIDArray);
public String getSymbol();
String getSymbol();
public void setSymbol(@MaxSize(20) String symbol);
void setSymbol(@MaxSize(20) String symbol);
String getCurrencyCode();
void setCurrencyCode(@MaxSize(4) String currencyCode);
public String getCurrencyCode();
void setInstrumentIDAt(@MaxSize(2) int location, TestInstrumentIDVOInterface instrumentID);
public void setCurrencyCode(@MaxSize(4) String currencyCode);
public void setInstrumentIDAt(@MaxSize(2) int location, TestInstrumentIDVOInterface instrumentID);
public TestInstrumentIDVOInterface getInstrumentIDAt(int location);
TestInstrumentIDVOInterface getInstrumentIDAt(int location);
interface TestInstrumentIDVOInterface {
public String getIdSource();
String getIdSource();
public void setIdSource(@MaxSize(6) String idSource);
void setIdSource(@MaxSize(6) String idSource);
public String getSecurityId();
String getSecurityId();
public void setSecurityId(@MaxSize(100) String securityId);
void setSecurityId(@MaxSize(100) String securityId);
}
}
@@ -82,7 +82,7 @@ public class AcquireGetUsingMain {
System.out.println("2 " + data.getTimeAt(1));
}
public static interface Data {
public interface Data {
void setTimeAt(@MaxSize(8) int index, long time);
long getTimeAt(int index);
@@ -82,7 +82,7 @@ public class CHMMetaDataTest {
@Override
public void onRemove(Bytes entry, long metaDataPos, long keyPos, long valuePos, boolean replicationEvent) {
System.out.println("Removed entry with ts of " + entry.readLong(metaDataPos));;
System.out.println("Removed entry with ts of " + entry.readLong(metaDataPos));
}
}
}
@@ -229,14 +229,14 @@ public class CHMTest5 {
}
}
public static interface CHMTest5Data {
public int getMaxNumberOfProcessesAllowed();
public interface CHMTest5Data {
int getMaxNumberOfProcessesAllowed();
public void setMaxNumberOfProcessesAllowed(int max);
void setMaxNumberOfProcessesAllowed(int max);
public void setTimeAt(@MaxSize(4) int index, long time);
void setTimeAt(@MaxSize(4) int index, long time);
public long getTimeAt(int index);
long getTimeAt(int index);
boolean compareAndSwapMaxNumberOfProcessesAllowed(int expected, int value);
@@ -1259,7 +1259,7 @@ public class ChronicleMapTest {
@Test
public void mapRemoveReflectedInViews() throws IOException {
try (ChronicleMap<Integer, CharSequence> map = getViewTestMap(3);) {
try (ChronicleMap<Integer, CharSequence> map = getViewTestMap(3)) {
Set<Map.Entry<Integer, CharSequence>> entrySet = map.entrySet();
Set<Integer> keySet = map.keySet();
Collection<CharSequence> values = map.values();
@@ -115,15 +115,15 @@ public class DemoChronicleMapTest {
}
interface DemoOrderVOInterface {
public CharSequence getSymbol();
CharSequence getSymbol();
// public StringBuilder getUsingSymbol(StringBuilder sb);
public void setSymbol(@MaxSize(20) CharSequence symbol);
void setSymbol(@MaxSize(20) CharSequence symbol);
public double addAtomicOrderQty(double toAdd);
double addAtomicOrderQty(double toAdd);
public double getOrderQty();
double getOrderQty();
public void setOrderQty(double orderQty);
void setOrderQty(double orderQty);
}
@@ -127,9 +127,9 @@ public class ProcessInstanceLimiterMain implements Runnable {
}
public interface Callback {
public void tooManyProcessesOfType(String processType);
void tooManyProcessesOfType(String processType);
public void noDefinitionForProcessesOfType(String processType);
void noDefinitionForProcessesOfType(String processType);
}
public static class Data implements Serializable {
@@ -36,9 +36,9 @@ public class RecursiveRefereneChMapTest {
.objectSerializer(JDKObjectSerializer.INSTANCE).create();
map.put("Test", new StupidCycle());
map.put("Test2", new StupidCycle2());
StupidCycle cycle = (StupidCycle) map.get("Test");
StupidCycle cycle = map.get("Test");
assertSame(cycle, cycle.cycle[0]);
StupidCycle cycle2 = (StupidCycle) map.get("Test2");
StupidCycle cycle2 = map.get("Test2");
assertSame(cycle2, cycle2.cycle[0]);
}
@@ -183,7 +183,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase {
@Test
public void testGet() throws IOException {
ChronicleMap map = map5();
assertEquals("A", (String) map.get(JSR166TestCase.one));
assertEquals("A", map.get(JSR166TestCase.one));
ChronicleMap empty = newShmIntString();
assertNull(map.get(JSR166TestCase.notPresent));
}
@@ -102,7 +102,7 @@ public class ReplicationCheckingMap<K, V> implements ChronicleMap<K, V> {
if (r1 != null)
Assert.assertEquals(r1.toString(), r2.toString());
return (R) r1;
return r1;
}
@Override
@@ -160,9 +160,8 @@ public class SerializerTest {
MyTestClassExternalizable that = (MyTestClassExternalizable) o;
if (a != that.a) return false;
return a == that.a;
return true;
}
@Override
@@ -195,9 +194,8 @@ public class SerializerTest {
MyTestClass myTestClass = (MyTestClass) o;
if (a != myTestClass.a) return false;
return a == myTestClass.a;
return true;
}
@Override
@@ -227,9 +225,8 @@ public class SerializerTest {
MyTestClassMarshallable that = (MyTestClassMarshallable) o;
if (a != that.a) return false;
return a == that.a;
return true;
}
@Override
@@ -269,10 +266,8 @@ public class SerializerTest {
MyTestClassObjectGraph that = (MyTestClassObjectGraph) o;
if (delegate != null ? !delegate.equals(that.delegate) : that.delegate != null)
return false;
return !(delegate != null ? !delegate.equals(that.delegate) : that.delegate != null);
return true;
}
@Override
@@ -134,9 +134,9 @@ public class TcpTimeBasedReplicationSoakTest {
final ChronicleMap<Integer, CharSequence> map = rnd.nextBoolean() ? map1 : map2;
if (rnd.nextBoolean()) {
map.put((int) rnd.nextInt(100), "test" + j);
map.put(rnd.nextInt(100), "test" + j);
} else {
map.remove((int) rnd.nextInt(100));
map.remove(rnd.nextInt(100));
}
}
@@ -99,7 +99,7 @@ public class LotsOfEntriesMain {
}
interface MyFloats {
public void setValueAt(@MaxSize(6) int index, float f);
void setValueAt(@MaxSize(6) int index, float f);
public float getValueAt(int index);
float getValueAt(int index);
}
@@ -160,8 +160,7 @@ public class BondVOInterface$$Heap implements BondVOInterface, BytesMarshallable
for (int i = 0; i <7; i++) {
if(!isEqual(getMarketPxIntraDayHistoryAt(i), that.getMarketPxIntraDayHistoryAt(i))) return false;
}
if(!isEqual(getSymbol(), that.getSymbol())) return false;
return true;
return isEqual(getSymbol(), that.getSymbol());
}
public String toString() {
@@ -139,7 +139,7 @@ public class BondVOInterface$$Native
this._bytes = bytes;
this._offset = offset;
for (int i = 0; i < 7; i++){
((Byteable) _marketPxIntraDayHistory[i]).bytes(bytes,
_marketPxIntraDayHistory[i].bytes(bytes,
_offset + MARKETPXINTRADAYHISTORY + (i * 40));
}
}
@@ -189,8 +189,7 @@ public class BondVOInterface$$Native
if(!isEqual(getMarketPxIntraDayHistoryAt(i), that.getMarketPxIntraDayHistoryAt(i)))
return false;
}
if(!isEqual(getSymbol(), that.getSymbol())) return false;
return true;
return isEqual(getSymbol(), that.getSymbol());
}
public String toString() {
@@ -116,8 +116,7 @@ public class BondVOInterface$MarketPx$$Heap implements MarketPx, BytesMarshallab
if(!isEqual(getBidPx(), that.getBidPx())) return false;
if(!isEqual(getCallPx(), that.getCallPx())) return false;
if(!isEqual(getMaturityPx(), that.getMaturityPx())) return false;
if(!isEqual(getParPx(), that.getParPx())) return false;
return true;
return isEqual(getParPx(), that.getParPx());
}
public String toString() {
@@ -151,8 +151,7 @@ public class BondVOInterface$MarketPx$$Native
if(!isEqual(getBidPx(), that.getBidPx())) return false;
if(!isEqual(getCallPx(), that.getCallPx())) return false;
if(!isEqual(getMaturityPx(), that.getMaturityPx())) return false;
if(!isEqual(getParPx(), that.getParPx())) return false;
return true;
return isEqual(getParPx(), that.getParPx());
}
public String toString() {
@@ -114,7 +114,7 @@ public class ChronicleMapTest extends JSR166TestCase {
@Test(timeout = 5000)
public void testGet() throws IOException {
try (ChronicleMap map = map5()) {
assertEquals("A", (String) map.get(one));
assertEquals("A", map.get(one));
try (ChronicleMap empty = newStrStrMap(8078)) {
assertNull(map.get(notPresent));
}
@@ -386,7 +386,7 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
@Test(timeout = 10000)
public void testGet() throws IOException {
try (ChronicleMap map = map5(s_port++)) {
assertEquals("A", (String) map.get(one));
assertEquals("A", map.get(one));
try (ChronicleMap empty = newStrStrMap(8078)) {
assertNull(map.get(notPresent));
}
@@ -458,14 +458,14 @@ public class ProcessInstanceLimiter implements Runnable {
* The Callback interface holds all the calls that can be made by the
* process instance limiter.
*/
public static interface Callback {
public interface Callback {
/**
* Called when there are already the specified number of processes of
* the given type running, and this process is one too many.
*
* @param processType - the name of the type of process being limited
*/
public void tooManyProcessesOfType(String processType);
void tooManyProcessesOfType(String processType);
/**
* Called when there is a lock conflict in the limiter
@@ -474,7 +474,7 @@ public class ProcessInstanceLimiter implements Runnable {
* @param processType - the name of the type of process being limited
* @param index - the slot number held by the other process
*/
public void lockConflictDetected(String processType, int index);
void lockConflictDetected(String processType, int index);
/**
* Called when another process has started and successfully acquired a
@@ -484,7 +484,7 @@ public class ProcessInstanceLimiter implements Runnable {
* @param slot - the slot number held by the other process
* @param startTime - the start timestamp of the other process
*/
public void anotherProcessHasStartedOnSlot(String processType, int slot, long startTime);
void anotherProcessHasStartedOnSlot(String processType, int slot, long startTime);
/**
* Called when this process has started and successfully acquired a slot
@@ -493,7 +493,7 @@ public class ProcessInstanceLimiter implements Runnable {
* @param processType - the name of the type of process being limited
* @param slot - the slot number held by this process
*/
public void thisProcessOfTypeHasStartedAtSlot(String processType, int slot);
void thisProcessOfTypeHasStartedAtSlot(String processType, int slot);
/**
* Called if the process was started but there was no data defined in
@@ -501,7 +501,7 @@ public class ProcessInstanceLimiter implements Runnable {
*
* @param processType - the name of the type of process being limited
*/
public void noDefinitionForProcessesOfType(String processType);
void noDefinitionForProcessesOfType(String processType);
/**
* Called when another process somehow managed to steal the slot that
@@ -510,7 +510,7 @@ public class ProcessInstanceLimiter implements Runnable {
* @param processType - the name of the type of process being limited
* @param slot - the slot number held by this process
*/
public void anotherProcessHasHijackedThisSlot(String processType, int slot);
void anotherProcessHasHijackedThisSlot(String processType, int slot);
}
/**
@@ -519,7 +519,7 @@ public class ProcessInstanceLimiter implements Runnable {
*
* The Timelock field is just for locking the time field
*/
public static interface Data {
public interface Data {
void setTimeAt(@MaxSize(50) int index, long time);
long getTimeAt(int index);
@@ -126,8 +126,7 @@ public class IntValue$$Native implements IntValue, BytesMarshallable, Byteable,
if (!(o instanceof IntValue)) return false;
IntValue that = (IntValue) o;
if (!isEqual(getValue(), that.getValue())) return false;
return true;
return isEqual(getValue(), that.getValue());
}
public String toString() {
@@ -108,8 +108,7 @@ public class LongValue$$Native implements LongValue, BytesMarshallable, Byteable
if (!(o instanceof LongValue)) return false;
LongValue that = (LongValue) o;
if (!isEqual(getValue(), that.getValue())) return false;
return true;
return isEqual(getValue(), that.getValue());
}
public String toString() {