use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class SequencerViewTest method checkBackPointersWork.
@Test
public void checkBackPointersWork() {
CorfuRuntime r = getDefaultRuntime();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
UUID streamB = UUID.nameUUIDFromBytes("stream B".getBytes());
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 1).getBackpointerMap()).containsEntry(streamA, Address.NON_EXIST);
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 0).getBackpointerMap()).isEmpty();
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 1).getBackpointerMap()).containsEntry(streamB, Address.NON_EXIST);
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 0).getBackpointerMap()).isEmpty();
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 1).getBackpointerMap()).containsEntry(streamA, 0L);
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 1).getBackpointerMap()).containsEntry(streamB, 1L);
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class SequencerViewTest method checkStreamTokensWork.
@Test
public void checkStreamTokensWork() {
CorfuRuntime r = getDefaultRuntime();
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
UUID streamB = UUID.nameUUIDFromBytes("stream B".getBytes());
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 1).getToken()).isEqualTo(new Token(0L, 0L));
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 0).getToken()).isEqualTo(new Token(0L, 0L));
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 1).getToken()).isEqualTo(new Token(1L, 0L));
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamB), 0).getToken()).isEqualTo(new Token(1L, 0L));
assertThat(r.getSequencerView().nextToken(Collections.singleton(streamA), 0).getToken()).isEqualTo(new Token(0L, 0L));
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class StreamViewTest method canReadWriteFromCachedStream.
@Test
@SuppressWarnings("unchecked")
public void canReadWriteFromCachedStream() throws Exception {
CorfuRuntime r = getDefaultRuntime().connect().setCacheDisabled(false);
UUID streamA = UUID.nameUUIDFromBytes("stream A".getBytes());
byte[] testPayload = "hello world".getBytes();
IStreamView sv = r.getStreamsView().get(streamA);
sv.append(testPayload);
assertThat(sv.next().getPayload(getRuntime())).isEqualTo("hello world".getBytes());
assertThat(sv.next()).isEqualTo(null);
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class LayoutViewTest method canSetLayout.
@Test
public void canSetLayout() throws Exception {
CorfuRuntime r = getDefaultRuntime().connect();
Layout l = new TestLayoutBuilder().setEpoch(1).addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addToSegment().addToLayout().build();
l.setRuntime(r);
l.moveServersToEpoch();
r.getLayoutView().updateLayout(l, 1L);
r.invalidateLayout();
assertThat(r.getLayoutView().getLayout().epoch).isEqualTo(1L);
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class ObjectsViewTest method cannotCopyNonCorfuObject.
@Test
@SuppressWarnings("unchecked")
public void cannotCopyNonCorfuObject() throws Exception {
//begin tests
CorfuRuntime r = getDefaultRuntime();
assertThatThrownBy(() -> {
r.getObjectsView().copy(new HashMap<String, String>(), CorfuRuntime.getStreamID("test"));
}).isInstanceOf(RuntimeException.class);
}
Aggregations