MINOR: Clean up some dead code around PQ + PQ Benchmarks

Fixes #8232
This commit is contained in:
Armin 2017-09-13 13:46:35 +02:00 committed by Armin Braun
parent af6b610b9e
commit 44e68b4627
13 changed files with 21 additions and 46 deletions

View file

@ -1,7 +1,6 @@
package org.logstash.benchmark; package org.logstash.benchmark;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -39,7 +38,7 @@ public class EventSerializationBenchmark {
private static final Event EVENT = new Event(); private static final Event EVENT = new Event();
@Setup @Setup
public void setUp() throws IOException { public void setUp() {
EVENT.setField("Foo", "Bar"); EVENT.setField("Foo", "Bar");
EVENT.setField("Foo1", "Bar1"); EVENT.setField("Foo1", "Bar1");
EVENT.setField("Foo2", "Bar2"); EVENT.setField("Foo2", "Bar2");

View file

@ -1,6 +1,5 @@
package org.logstash.benchmark; package org.logstash.benchmark;
import java.io.IOException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.logstash.Event; import org.logstash.Event;
import org.logstash.Timestamp; import org.logstash.Timestamp;
@ -34,7 +33,7 @@ public class EventSprintfBenchmark {
private static final Event EVENT = new Event(); private static final Event EVENT = new Event();
@Setup @Setup
public void setUp() throws IOException { public void setUp() {
EVENT.setField("Foo", "Bar"); EVENT.setField("Foo", "Bar");
EVENT.setField("Foo1", "Bar1"); EVENT.setField("Foo1", "Bar1");
EVENT.setField("Foo2", "Bar2"); EVENT.setField("Foo2", "Bar2");

View file

@ -66,7 +66,7 @@ public class QueueRWBenchmark {
private ExecutorService exec; private ExecutorService exec;
@Setup @Setup
public void setUp() throws IOException, CloneNotSupportedException { public void setUp() throws IOException {
final Settings settingsPersisted = settings(true); final Settings settingsPersisted = settings(true);
EVENT.setField("Foo", "Bar"); EVENT.setField("Foo", "Bar");
EVENT.setField("Foo1", "Bar1"); EVENT.setField("Foo1", "Bar1");

View file

@ -740,7 +740,7 @@ public class Queue implements Closeable {
} }
} }
protected Page firstUnreadPage() throws IOException { protected Page firstUnreadPage() {
// look at head page if no unreadTailPages // look at head page if no unreadTailPages
return (this.unreadTailPages.isEmpty()) ? (this.headPage.isFullyRead() ? null : this.headPage) : this.unreadTailPages.get(0); return (this.unreadTailPages.isEmpty()) ? (this.headPage.isFullyRead() ? null : this.headPage) : this.unreadTailPages.get(0);
} }

View file

@ -2,28 +2,8 @@ package org.logstash.ackedqueue;
public class QueueRuntimeException extends RuntimeException { public class QueueRuntimeException extends RuntimeException {
public static QueueRuntimeException newFormatMessage(String fmt, Object... args) {
return new QueueRuntimeException(
String.format(fmt, args)
);
}
public QueueRuntimeException() {
}
public QueueRuntimeException(String message) {
super(message);
}
public QueueRuntimeException(String message, Throwable cause) { public QueueRuntimeException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
public QueueRuntimeException(Throwable cause) {
super(cause);
}
public QueueRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
} }

View file

@ -185,7 +185,7 @@ public abstract class AbstractByteBufferPageIO implements PageIO {
} }
@Override @Override
public void write(byte[] bytes, long seqNum) throws IOException { public void write(byte[] bytes, long seqNum) {
write(bytes, seqNum, bytes.length, checksum(bytes)); write(bytes, seqNum, bytes.length, checksum(bytes));
} }

View file

@ -1,25 +1,24 @@
package org.logstash.ackedqueue.io; package org.logstash.ackedqueue.io;
import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public class ByteBufferPageIO extends AbstractByteBufferPageIO { public class ByteBufferPageIO extends AbstractByteBufferPageIO {
private final ByteBuffer buffer; private final ByteBuffer buffer;
public ByteBufferPageIO(int pageNum, int capacity, String path) throws IOException { public ByteBufferPageIO(int pageNum, int capacity, String path) {
this(capacity, new byte[0]); this(capacity, new byte[0]);
} }
public ByteBufferPageIO(int capacity) throws IOException { public ByteBufferPageIO(int capacity) {
this(capacity, new byte[0]); this(capacity, new byte[0]);
} }
public ByteBufferPageIO(int capacity, byte[] initialBytes) throws IOException { public ByteBufferPageIO(int capacity, byte[] initialBytes) {
super(0, capacity); super(0, capacity);
if (initialBytes.length > capacity) { if (initialBytes.length > capacity) {
throw new IOException("initial bytes greater than capacity"); throw new IllegalArgumentException("initial bytes greater than capacity");
} }
this.buffer = ByteBuffer.allocate(capacity); this.buffer = ByteBuffer.allocate(capacity);

View file

@ -14,7 +14,7 @@ public interface CheckpointIO {
void purge(String fileName) throws IOException; void purge(String fileName) throws IOException;
void purge() throws IOException; void purge();
// @return the head page checkpoint file name // @return the head page checkpoint file name
String headFileName(); String headFileName();

View file

@ -83,7 +83,7 @@ public class FileCheckpointIO implements CheckpointIO {
} }
@Override @Override
public void purge() throws IOException { public void purge() {
// TODO: dir traversal and delete all checkpoints? // TODO: dir traversal and delete all checkpoints?
throw new UnsupportedOperationException("purge() is not supported"); throw new UnsupportedOperationException("purge() is not supported");
} }

View file

@ -37,14 +37,14 @@ public class MemoryCheckpointIO implements CheckpointIO {
} }
@Override @Override
public Checkpoint write(String fileName, int pageNum, int firstUnackedPageNum, long firstUnackedSeqNum, long minSeqNum, int elementCount) throws IOException { public Checkpoint write(String fileName, int pageNum, int firstUnackedPageNum, long firstUnackedSeqNum, long minSeqNum, int elementCount) {
Checkpoint checkpoint = new Checkpoint(pageNum, firstUnackedPageNum, firstUnackedSeqNum, minSeqNum, elementCount); Checkpoint checkpoint = new Checkpoint(pageNum, firstUnackedPageNum, firstUnackedSeqNum, minSeqNum, elementCount);
write(fileName, checkpoint); write(fileName, checkpoint);
return checkpoint; return checkpoint;
} }
@Override @Override
public void write(String fileName, Checkpoint checkpoint) throws IOException { public void write(String fileName, Checkpoint checkpoint) {
Map<String, Checkpoint> ns = sources.get(dirPath); Map<String, Checkpoint> ns = sources.get(dirPath);
if (ns == null) { if (ns == null) {
ns = new HashMap<>(); ns = new HashMap<>();

View file

@ -1,8 +1,6 @@
package org.logstash.ackedqueue.io; package org.logstash.ackedqueue.io;
import java.io.IOException;
@FunctionalInterface @FunctionalInterface
public interface PageIOFactory { public interface PageIOFactory {
PageIO build(int pageNum, int capacity, String dirPath) throws IOException; PageIO build(int pageNum, int capacity, String dirPath);
} }

View file

@ -13,7 +13,7 @@ public class ByteBufferStreamInput extends StreamInput {
} }
@Override @Override
public int read() throws IOException { public int read() {
if (!buffer.hasRemaining()) { if (!buffer.hasRemaining()) {
return -1; return -1;
} }
@ -29,7 +29,7 @@ public class ByteBufferStreamInput extends StreamInput {
} }
@Override @Override
public int read(byte[] b, int off, int len) throws IOException { public int read(byte[] b, int off, int len) {
if (!buffer.hasRemaining()) { if (!buffer.hasRemaining()) {
return -1; return -1;
} }
@ -59,7 +59,7 @@ public class ByteBufferStreamInput extends StreamInput {
} }
@Override @Override
public void reset() throws IOException { public void reset() {
buffer.reset(); buffer.reset();
} }
@ -68,7 +68,7 @@ public class ByteBufferStreamInput extends StreamInput {
} }
@Override @Override
public int available() throws IOException { public int available() {
return buffer.remaining(); return buffer.remaining();
} }
@ -83,7 +83,7 @@ public class ByteBufferStreamInput extends StreamInput {
} }
@Override @Override
public void close() throws IOException { public void close() {
} }
} }

View file

@ -51,7 +51,7 @@ public class ByteBufferPageIOTest {
return io; return io;
} }
private static ByteBufferPageIO newPageIO(int capacity, byte[] bytes) throws IOException { private static ByteBufferPageIO newPageIO(int capacity, byte[] bytes) {
return new ByteBufferPageIO(capacity, bytes); return new ByteBufferPageIO(capacity, bytes);
} }