Skip to content

Commit

Permalink
refactors from running the code inspector in idea
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Austin committed Jan 22, 2016
1 parent ec4f656 commit 42389dc
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 57 deletions.
Expand Up @@ -68,7 +68,6 @@ public interface ChronicleQueue extends Closeable {
* An Excerpt can be used access entries randomly and optionally change them.
*
* @return Excerpt
* @throws IOException if an IO problem occurs
*/
@NotNull
Excerpt createExcerpt();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/openhft/chronicle/queue/RollCycle.java
Expand Up @@ -72,7 +72,7 @@ public ZoneId zone() {
ZoneId zone();

/**
* @param epoch and EPOC offset, to all the user to define thier own epoch
* @param epoch and EPOCH offset, to all the user to define thier own epoch
* @return the cycle
*/
default int current(long epoch) {
Expand Down
Expand Up @@ -85,9 +85,8 @@ public WireType wireType() {
* @param epoch an epoch offset as the number of number of milliseconds since January 1, 1970,
* 00:00:00 GMT
* @return the {@code WireStore} associated with this {@code cycle}
* @throws IOException
*/
protected abstract WireStore storeForCycle(long cycle, final long epoch) throws IOException;
protected abstract WireStore storeForCycle(long cycle, final long epoch);

/**
* @param store the {@code store} to release
Expand Down
Expand Up @@ -15,17 +15,12 @@
*/
package net.openhft.chronicle.queue.impl;

import net.openhft.chronicle.bytes.Bytes;
import net.openhft.chronicle.bytes.MappedBytes;
import net.openhft.chronicle.core.ReferenceCounted;
import net.openhft.chronicle.queue.ChronicleQueueBuilder;
import net.openhft.chronicle.wire.Marshallable;
import net.openhft.chronicle.wire.Wire;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.Closeable;
import java.util.function.Function;

public interface WireStore extends ReferenceCounted, Marshallable {

Expand Down Expand Up @@ -63,9 +58,7 @@ void install(
long length,
boolean created,
long cycle,
@NotNull ChronicleQueueBuilder builder,
@NotNull Function<Bytes, Wire> wireSupplier,
@Nullable Closeable closeable)
@NotNull ChronicleQueueBuilder builder)
;

@NotNull
Expand Down
Expand Up @@ -96,7 +96,7 @@ public ExcerptTailer createTailer() throws IOException {
}

@Override
protected WireStore storeForCycle(long cycle, final long epoch) throws IOException {
protected WireStore storeForCycle(long cycle, final long epoch) {
return this.pool.acquire(cycle, epoch);
}

Expand Down Expand Up @@ -130,8 +130,8 @@ private long firstCycle() {

if (files != null && files.length > 0) {
long firstDate = Long.MAX_VALUE;
long date = -1;
String name = null;
long date;
String name;

for (int i = files.length - 1; i >= 0; i--) {
try {
Expand Down Expand Up @@ -259,9 +259,7 @@ private WireStore acquireStore(final long cycle, final long epoch) {
ws.headerLength(),
ws.headerCreated(),
cycle,
builder,
ws.wireSupplier(),
ws.mappedBytes()
builder
);

};
Expand Down
Expand Up @@ -34,7 +34,6 @@
import java.io.Closeable;
import java.io.IOException;
import java.time.ZoneId;
import java.util.function.Function;

import static java.lang.ThreadLocal.withInitial;
import static net.openhft.chronicle.queue.impl.single.SingleChronicleQueueStore.IndexOffset.toAddress0;
Expand Down Expand Up @@ -197,13 +196,8 @@ public long refCount() {
// *************************************************************************

@Override
public void install(
long length,
boolean created,
long cycle,
@NotNull ChronicleQueueBuilder builder,
@NotNull Function<Bytes, Wire> wireSupplier,
@Nullable Closeable closeable) {
public void install(long length, boolean created, long cycle,
@NotNull ChronicleQueueBuilder builder) {

this.builder = (SingleChronicleQueueBuilder) builder;

Expand Down Expand Up @@ -279,8 +273,8 @@ public void readMarshallable(@NotNull WireIn wire) throws IORuntimeException {
wireType = wire.read(MetaDataField.wireType).object(WireType.class);
wire.read(MetaDataField.bounds).marshallable(this.bounds);
wire.read(MetaDataField.roll).marshallable(this.roll);
long chunkSize = wire.read(MetaDataField.chunkSize).int64();
long overlapSize = wire.read(MetaDataField.overlapSize).int64();
wire.read(MetaDataField.chunkSize).int64();
wire.read(MetaDataField.overlapSize).int64();

final MappedBytes mappedBytes = (MappedBytes) (wire.bytes());
this.mappedFile = mappedBytes.mappedFile();
Expand Down
Expand Up @@ -20,8 +20,8 @@

import net.openhft.affinity.Affinity;
import net.openhft.affinity.AffinityLock;
import net.openhft.chronicle.bytes.IORuntimeException;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.io.IORuntimeException;
import net.openhft.chronicle.core.util.Histogram;
import net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder;
import net.openhft.chronicle.wire.*;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void test() throws Exception {
}

static class MyWriteMarshallable implements WriteMarshallable {
private TestTrade bt;
private final TestTrade bt;

public MyWriteMarshallable(TestTrade bt) {

Expand All @@ -123,10 +123,10 @@ public void writeMarshallable(WireOut w) {
}

static class MyReadMarshallable implements ReadMarshallable {
StringBuilder messageType = new StringBuilder();
AtomicInteger counter = new AtomicInteger(0);
private Histogram histogram;
TestTrade testTrade = new TestTrade();
final StringBuilder messageType = new StringBuilder();
final AtomicInteger counter = new AtomicInteger(0);
private final Histogram histogram;
final TestTrade testTrade = new TestTrade();

public MyReadMarshallable(Histogram histogram) {
this.histogram = histogram;
Expand Down
Expand Up @@ -51,9 +51,9 @@
*/
public class ChronicleQueueLatencyDistributionWithBytes extends ChronicleQueueTestBase {

public static final int BYTES_LENGTH = 256;
public static final int BLOCK_SIZE = 256 << 20;
public static final int BUFFER_CAPACITY = 256 << 10;
private static final int BYTES_LENGTH = 256;
private static final int BLOCK_SIZE = 256 << 20;
private static final int BUFFER_CAPACITY = 256 << 10;
private static final long INTERVAL_US = 10;

@Ignore("long running")
Expand Down
Expand Up @@ -33,9 +33,9 @@ public class ChronicleQueueMicrobench {
protected static final int DEFAULT_WARMUP_ITERATIONS = 10;
protected static final int DEFAULT_MEASURE_ITERATIONS = 10;

protected static final String[] EMPTY_JVM_ARGS = {};
private static final String[] EMPTY_JVM_ARGS = {};

protected static final String[] BASE_JVM_ARGS = {
private static final String[] BASE_JVM_ARGS = {
"-server",
"-dsa",
"-da",
Expand All @@ -51,7 +51,7 @@ public class ChronicleQueueMicrobench {
//
// *************************************************************************

protected ChainedOptionsBuilder newOptionsBuilder() {
private ChainedOptionsBuilder newOptionsBuilder() {
String className = getClass().getSimpleName();

final ChainedOptionsBuilder runnerOptions = new OptionsBuilder()
Expand Down Expand Up @@ -85,19 +85,19 @@ protected ChainedOptionsBuilder newOptionsBuilder() {
return runnerOptions;
}

protected String[] jvmArgs() {
private String[] jvmArgs() {
return EMPTY_JVM_ARGS;
}

protected int getWarmupIterations() {
private int getWarmupIterations() {
return Integer.getInteger("warmupIterations", -1);
}

protected int getMeasureIterations() {
private int getMeasureIterations() {
return Integer.getInteger("measureIterations", -1);
}

protected String getReportDir() {
private String getReportDir() {
return System.getProperty("perfReportDir");
}

Expand Down
Expand Up @@ -33,7 +33,7 @@

public class ChronicleQueueTestBase {
protected static final Logger LOGGER = LoggerFactory.getLogger(ChronicleQueueTestBase.class);
protected static final boolean TRACE_TEST_EXECUTION = Boolean.getBoolean("queue.traceTestExecution");
private static final boolean TRACE_TEST_EXECUTION = Boolean.getBoolean("queue.traceTestExecution");

// *************************************************************************
// JUNIT Rules
Expand Down Expand Up @@ -65,15 +65,15 @@ protected void starting(Description description) {
//
// *************************************************************************

public static enum TestKey implements WireKey {
public enum TestKey implements WireKey {
test
}

// *************************************************************************
//
// *************************************************************************

public static File getTmpDir() {
protected static File getTmpDir() {
try {
final File tmpDir = Files.createTempDirectory("chronicle" + "-").toFile();

Expand Down Expand Up @@ -131,11 +131,10 @@ private static void deleteDir(File dir) {
if (dir.isDirectory()) {
File[] files = dir.listFiles();
if (files != null) {
File[] arr$ = files;
int len$ = files.length;

for (int i$ = 0; i$ < len$; ++i$) {
File file = arr$[i$];
File file = files[i$];
if (file.isDirectory()) {
deleteDir(file);
} else if (!file.delete()) {
Expand Down
Expand Up @@ -36,7 +36,7 @@
@RunWith(Parameterized.class)
public class SingleChronicleQueueTest extends ChronicleQueueTestBase {

public static final long TIMES = (4L << 20L);
private static final long TIMES = (4L << 20L);

@Parameterized.Parameters
public static Collection<Object[]> data() {
Expand Down Expand Up @@ -321,8 +321,7 @@ public void testReadAtIndex() throws Exception {
// create 100 documents
for (int i = 0; i < 100; i++) {
final int j = i;
final long index = appender.writeDocument(wire -> wire.write(() -> "key").text("value=" + j));
lastIndex = index;
lastIndex = appender.writeDocument(wire -> wire.write(() -> "key").text("value=" + j));
}


Expand Down Expand Up @@ -361,12 +360,11 @@ public void testReadAtIndex4MB() throws Exception {

long lastIndex = -1;
System.out.print("Percent written=");
long writtenPercent = 0;

// create 100 documents
for (long i = 0; i < TIMES; i++) {
final long j = i;
final long index = appender.writeDocument(wire -> wire.write(() -> "key").text("value=" + j));
lastIndex = index;
lastIndex = appender.writeDocument(wire -> wire.write(() -> "key").text("value=" + j));

if (i % (TIMES / 20) == 0) {
System.out.println("" + (i * 100 / TIMES) + "%, ");
Expand Down Expand Up @@ -559,6 +557,4 @@ public void testIndex() throws Exception {
}




}

0 comments on commit 42389dc

Please sign in to comment.