reduce white space lines

This commit is contained in:
Peter Lawrey
2016-01-01 09:29:06 +00:00
parent e0cb22f22b
commit ab12d46956
36 changed files with 81 additions and 182 deletions
@@ -206,6 +206,5 @@ public abstract class AbstractReplication implements Serializable {
return ", udpConfig=" + udpConfig +
", remoteNodeValidator=" + remoteNodeValidator;
}
}
}
@@ -32,17 +32,6 @@ public abstract class ByteableMarshaller<E extends Byteable>
DeserializationFactoryConfigurableBytesReader<E, ByteableMarshaller<E>>,
SizeMarshaller {
private static final long serialVersionUID = 0L;
public static <E extends Byteable> ByteableMarshaller<E> of(@NotNull Class<E> eClass) {
return new Default<>(eClass);
}
@Override
public ByteableMarshaller<E> withDeserializationFactory(
ObjectFactory<E> deserializationFactory) {
return new WithCustomFactory<>(tClass, deserializationFactory);
}
@NotNull
private final Class<E> tClass;
private long size;
@@ -51,6 +40,27 @@ public abstract class ByteableMarshaller<E extends Byteable>
this.tClass = tClass;
}
public static <E extends Byteable> ByteableMarshaller<E> of(@NotNull Class<E> eClass) {
return new Default<>(eClass);
}
public static void setBytesAndOffset(Byteable e, Bytes bytes) {
// use the unshifting underlying Bytes (the position never changes)
// if you use a Bytes where the position changes, you risk concurrency issues.
if (bytes instanceof MultiStoreBytes) {
MultiStoreBytes msb = (MultiStoreBytes) bytes;
e.bytes(msb.underlyingBytes(), msb.underlyingOffset() + msb.position());
} else {
e.bytes(bytes, bytes.position());
}
}
@Override
public ByteableMarshaller<E> withDeserializationFactory(
ObjectFactory<E> deserializationFactory) {
return new WithCustomFactory<>(tClass, deserializationFactory);
}
void initSize() {
try {
size = getInstance().maxSize();
@@ -148,17 +158,6 @@ public abstract class ByteableMarshaller<E extends Byteable>
}
}
public static void setBytesAndOffset(Byteable e, Bytes bytes) {
// use the unshifting underlying Bytes (the position never changes)
// if you use a Bytes where the position changes, you risk concurrency issues.
if (bytes instanceof MultiStoreBytes) {
MultiStoreBytes msb = (MultiStoreBytes) bytes;
e.bytes(msb.underlyingBytes(), msb.underlyingOffset() + msb.position());
} else {
e.bytes(bytes, bytes.position());
}
}
@SuppressWarnings("unchecked")
@NotNull
E getInstance() throws Exception {
@@ -192,8 +191,6 @@ public abstract class ByteableMarshaller<E extends Byteable>
super(tClass);
initSize();
}
}
private static class WithCustomFactory<E extends Byteable> extends ByteableMarshaller<E> {
@@ -214,7 +211,5 @@ public abstract class ByteableMarshaller<E extends Byteable>
E getInstance() throws Exception {
return factory.create();
}
}
}
@@ -136,6 +136,5 @@ class DirectBytesBuffer
private ForDataValueWriter() {
super(DirectBytesBuffer.this);
}
}
}
@@ -555,9 +555,9 @@ abstract class AbstractChannelReplicator implements Closeable {
entry.position(startOfEntry);
return onEntry(entry, chronicleId, bootstrapTime);
} else
} else {
throw e;
}
}
return true;
}
@@ -647,7 +647,6 @@ abstract class AbstractChannelReplicator implements Closeable {
public void setSuccessfullyConnected() {
connectionAttempts = 0;
}
}
}
@@ -78,7 +78,6 @@ class JsonSerializer {
" expecting an object of type com.thoughtworks.xstream.converters" +
".Converter");
}
}
return xstream;
@@ -130,7 +130,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
while (destination.remaining() > 0 && source.remaining() > 0) {
destination.writeByte(source.readByte());
}
}
private int assignedModIterBitSetSizeInBytes() {
@@ -311,7 +310,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
} finally {
segment.writeUnlock();
}
}
@Override
@@ -645,7 +643,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
} finally {
entry.position(start);
}
}
/**
@@ -667,7 +664,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
final byte identifier = entry.readByte();
final boolean isDeleted = entry.readBoolean();
long valueSize;
if (!isDeleted) {
@@ -1726,7 +1722,6 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
entry.skip(keySize);
return entry.readLong();
}
}
class TimestampTrackingEntry extends SimpleEntry<K, V> {
@@ -262,7 +262,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
outBytes.position(position);
// outBytesLock.lock();
}
}
private byte[] copyBufferBytes() {
@@ -300,7 +299,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
if (closeables != null) closeables.closeQuietly();
clientChannel = null;
}
}
/**
@@ -817,7 +815,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
inBytesLock.unlock();
}
}
}
public void putAll(@NotNull Map<? extends K, ? extends V> map) {
@@ -1068,8 +1065,9 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
long limit = inBytes.position();
inBytes.position(limit);
resizeBufferInBuffer(remainingBytes, pos);
} else
} else {
inBytes.limit(inBytes.capacity());
}
try {
// block until we have received all the bytes in this chunk
@@ -1710,7 +1708,6 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
default:
return false;
}
}
private void writeObject(@NotNull Object function) {
@@ -1735,8 +1732,9 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
throw e;
}
} else
} else {
throw e;
}
}
}
}
@@ -1753,10 +1751,12 @@ class StatelessChronicleMap<K, V> implements ChronicleMap<K, V>, Closeable, Clon
long requiresExtra = size - outBytes.remaining();
resizeBufferOutBuffer((int) (outBytes.capacity() + requiresExtra), start);
} else
} else {
throw e;
} else
}
} else {
throw e;
}
}
@Nullable
@@ -98,7 +98,6 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
private long largestEntrySoFar = 128;
private long selectorTimeout;
/**
* @throws IOException on an io error.
*/
@@ -152,7 +151,6 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
}
};
start();
}
@@ -569,14 +567,14 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
if (!remoteVersion.equals(localVersion)) {
byte remoteIdentifier = attached.remoteIdentifier;
LOG.warn("DIFFERENT CHRONICLE-MAP VERSIONS : " +
"local-map=" + localVersion +
", remote-map-id-" + remoteIdentifier + "=" +
remoteVersion +
"local-map=" + localVersion +
", remote-map-id-" + remoteIdentifier + "=" +
remoteVersion +
", The Remote Chronicle Map with " +
"identifier=" + remoteIdentifier +
" and this Chronicle Map are on different " +
"versions, we suggest that you use the same version."
", The Remote Chronicle Map with " +
"identifier=" + remoteIdentifier +
" and this Chronicle Map are on different " +
"versions, we suggest that you use the same version."
);
}
@@ -817,8 +815,9 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
AbstractConnector connector = attached.connector;
if (connector != null)
connector.connectLater();
} else
} else {
socketChannel.close();
}
return;
}
@@ -1151,18 +1150,18 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
void resizeToMessage(@NotNull IllegalStateException e) {
String message = e.getMessage();
if (message.startsWith("java.io.IOException: Not enough available space for writing ")) {
if (!message.startsWith("java.io.IOException: Not enough available space for writing ")) {
throw e;
}
String substring = message.substring("java.io.IOException: Not enough available space for writing ".length(), message.length());
int i = substring.indexOf(' ');
if (i != -1) {
int size = Integer.parseInt(substring.substring(0, i));
long requiresExtra = size - in().remaining();
ensureBufferSize((int) (in().capacity() + requiresExtra));
} else
if (i == -1)
throw e;
} else
throw e;
int size = Integer.parseInt(substring.substring(0, i));
long requiresExtra = size - in().remaining();
ensureBufferSize((int) (in().capacity() + requiresExtra));
}
Bytes in() {
@@ -1500,12 +1499,13 @@ final class TcpReplicator<K, V> extends AbstractChannelReplicator implements Clo
* @return the timestamp or -1 if unsuccessful
*/
String readRemoteServerVersion() {
if (out.remaining() >= 64) {
char[] chars = new char[64];
out.readFully(chars, 0, chars.length);
return new String(chars).trim();
} else
if (out.remaining() < 64) {
return null;
}
char[] chars = new char[64];
out.readFully(chars, 0, chars.length);
return new String(chars).trim();
}
public long readRemoteHeartbeatIntervalFromBuffer() {
@@ -2163,7 +2163,6 @@ class StatelessServerConnector<K, V> {
out.limit(limit);
out.position(pos);
}
}
private void writeException(@NotNull TcpReplicator.TcpSocketChannelEntryWriter out, Throwable e) {
@@ -204,7 +204,6 @@ class UdpChannelReplicator extends AbstractChannelReplicator implements Replica.
if (!isClosed)
closeEarlyAndQuietly(key.channel());
}
}
private DatagramChannel connectClient() throws IOException {
@@ -705,7 +705,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
return result;
}
}
V putMapped0(K key, @NotNull UnaryOperator<V> unaryOperator) {
@@ -780,7 +779,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
long keySize = metaKeyInterop.size(keyInterop, key);
long hash = metaKeyInterop.hash(keyInterop, key);
int segmentNum = getSegment(hash);
long segmentHash = segmentHash(hash);
@@ -1371,7 +1369,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
public void write(Void writer, Bytes bytes, Bytes value) {
bytes.write(value, value.position(), value.remaining());
}
}
public static final class SegmentState implements StatefulCopyable<SegmentState>,
@@ -1894,7 +1891,6 @@ class VanillaChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? super KI>,
}
}
public WriteLocked<K, KI, MKI, V, VI, MVI> writeLock() {
return writeLock(null, false);
}
@@ -81,7 +81,6 @@ class AbstractChronicleMapConverter<K, V> implements Converter {
} catch (Exception e1) {
throw new ConversionException("class=" + clazz, e1);
}
}
}
@@ -111,7 +110,6 @@ class AbstractChronicleMapConverter<K, V> implements Converter {
}
writer.endNode();
}
}
@Override
@@ -196,7 +196,6 @@ public class DataValueConverter implements Converter {
} catch (Exception e) {
LOG.error("class=" + fileModel.name(), e);
}
}
} catch (ClassNotFoundException e) {
@@ -262,7 +261,6 @@ public class DataValueConverter implements Converter {
} catch (Exception e) {
throw new ConversionException("class=" + canonicalName, e);
}
}
private void fillInObject(HierarchicalStreamReader reader, UnmarshallingContext context, Object using) throws ClassNotFoundException {
@@ -72,7 +72,6 @@ public class StatelessChronicleMapConverter<K, V> extends AbstractChronicleMapCo
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new ConversionException("", e);
}
}
}
@@ -50,7 +50,6 @@ public class VanillaChronicleMapConverter<K, V> extends AbstractChronicleMapConv
}
writer.endNode();
}
}
}