Skip to content

Commit

Permalink
ChronicleQueue V4, initial code for builder
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Aug 14, 2015
1 parent 8b2f3e1 commit a63368c
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 84 deletions.
Expand Up @@ -15,85 +15,15 @@
*/ */
package net.openhft.chronicle.queue; package net.openhft.chronicle.queue;


import net.openhft.chronicle.wire.BinaryWire;
import net.openhft.chronicle.wire.TextWire;
import net.openhft.chronicle.wire.Wire;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;


import java.io.File;
import java.io.IOException; import java.io.IOException;


/** /**
* Created by peter.lawrey on 30/01/15. * Created by peter.lawrey on 30/01/15.
*/ */
public class ChronicleQueueBuilder implements Cloneable { public interface ChronicleQueueBuilder extends Cloneable {
private String name;
private long blockSize;
private Class<? extends Wire> wireType;

public ChronicleQueueBuilder(File name) {
this(name.getAbsolutePath());
}

public ChronicleQueueBuilder(String name) {
this.name = name;
this.blockSize = 64L << 20;
this.wireType = BinaryWire.class;
}

public String name() {
return this.name;
}

public ChronicleQueueBuilder blockSize(int blockSize) {
this.blockSize = blockSize;
return this;
}

public long blockSize() {
return this.blockSize;
}

public ChronicleQueueBuilder wireType(Class<? extends Wire> wireType) {
this.wireType = wireType;
return this;
}

public Class<? extends Wire> wireType() {
return this.wireType;
}


@NotNull @NotNull
public ChronicleQueue build() throws IOException { public ChronicleQueue build() throws IOException;
throw new UnsupportedOperationException("Not yet implemented");
}

@NotNull
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
@Override
public ChronicleQueueBuilder clone() {
try {
return (ChronicleQueueBuilder) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}

public static ChronicleQueueBuilder binary(File name) {
return binary(name.getAbsolutePath());
}

public static ChronicleQueueBuilder binary(String name) {
return new ChronicleQueueBuilder(name)
.wireType(BinaryWire.class);
}

public static ChronicleQueueBuilder text(File name) {
return text(name.getAbsolutePath());
}

public static ChronicleQueueBuilder text(String name) {
return new ChronicleQueueBuilder(name)
.wireType(TextWire.class);
}
} }
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2015 higherfrequencytrading.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package net.openhft.chronicle.queue.impl;

import net.openhft.chronicle.wire.WireIn;
import net.openhft.chronicle.wire.WireOut;

public abstract class AbstractChronicleQueueFormat implements ChronicleQueueFormat {

@Override
public void readMarshallable(WireIn wireIn) throws IllegalStateException {
throw new UnsupportedOperationException("Not implemented");
}

@Override
public void writeMarshallable(WireOut wireOut) {
throw new UnsupportedOperationException("Not implemented");
}
}
Expand Up @@ -18,5 +18,5 @@


import net.openhft.chronicle.queue.impl.AbstractChronicleQueue; import net.openhft.chronicle.queue.impl.AbstractChronicleQueue;


public class SingleChronicleQueue extends AbstractChronicleQueue { class SingleChronicleQueue extends AbstractChronicleQueue {
} }
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2015 higherfrequencytrading.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package net.openhft.chronicle.queue.impl.single;

import net.openhft.chronicle.queue.ChronicleQueue;
import net.openhft.chronicle.queue.ChronicleQueueBuilder;
import net.openhft.chronicle.wire.BinaryWire;
import net.openhft.chronicle.wire.TextWire;
import net.openhft.chronicle.wire.Wire;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;

public class SingleChronicleQueueBuilder implements ChronicleQueueBuilder {
private String name;
private long blockSize;
private Class<? extends Wire> wireType;

public SingleChronicleQueueBuilder(File name) {
this(name.getAbsolutePath());
}

public SingleChronicleQueueBuilder(String name) {
this.name = name;
this.blockSize = 64L << 20;
this.wireType = BinaryWire.class;
}

public String name() {
return this.name;
}

public SingleChronicleQueueBuilder blockSize(int blockSize) {
this.blockSize = blockSize;
return this;
}

public long blockSize() {
return this.blockSize;
}

public SingleChronicleQueueBuilder wireType(Class<? extends Wire> wireType) {
this.wireType = wireType;
return this;
}

public Class<? extends Wire> wireType() {
return this.wireType;
}

@NotNull
public ChronicleQueue build() throws IOException {
throw new UnsupportedOperationException("Not yet implemented");
}

@NotNull
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
@Override
public SingleChronicleQueueBuilder clone() {
try {
return (SingleChronicleQueueBuilder) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}

public static SingleChronicleQueueBuilder binary(File name) {
return binary(name.getAbsolutePath());
}

public static SingleChronicleQueueBuilder binary(String name) {
return new SingleChronicleQueueBuilder(name)
.wireType(BinaryWire.class);
}

public static SingleChronicleQueueBuilder text(File name) {
return text(name.getAbsolutePath());
}

public static SingleChronicleQueueBuilder text(String name) {
return new SingleChronicleQueueBuilder(name)
.wireType(TextWire.class);
}
}
Expand Up @@ -15,16 +15,7 @@
*/ */
package net.openhft.chronicle.queue.impl.single; package net.openhft.chronicle.queue.impl.single;


import net.openhft.chronicle.queue.impl.ChronicleQueueFormat; import net.openhft.chronicle.queue.impl.AbstractChronicleQueueFormat;
import net.openhft.chronicle.wire.WireIn;
import net.openhft.chronicle.wire.WireOut;


public class SingleChronicleQueueFormat implements ChronicleQueueFormat { class SingleChronicleQueueFormat extends AbstractChronicleQueueFormat {
@Override
public void readMarshallable(WireIn wireIn) throws IllegalStateException {
}

@Override
public void writeMarshallable(WireOut wireOut) {
}
} }

0 comments on commit a63368c

Please sign in to comment.