use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class SequencerViewTest method canAcquireFirstToken.
@Test
public void canAcquireFirstToken() {
CorfuRuntime r = getDefaultRuntime();
assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(0L, 0L));
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class SequencerViewTest method tokensAreIncrementing.
@Test
public void tokensAreIncrementing() {
CorfuRuntime r = getDefaultRuntime();
assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(0L, 0L));
assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(1L, 0L));
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class SequencerViewTest method checkTokenWorks.
@Test
public void checkTokenWorks() {
CorfuRuntime r = getDefaultRuntime();
assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 1).getToken()).isEqualTo(new Token(0L, 0L));
assertThat(r.getSequencerView().nextToken(Collections.emptySet(), 0).getToken()).isEqualTo(new Token(0L, 0L));
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class ManagementServer method failureDetectorTask.
/**
* This contains the complete failure detection and handling mechanism.
* <p>
* It first checks whether the current node is bootstrapped.
* If not, it continues checking in intervals of 1 second.
* If yes, it sets up the corfuRuntime and continues execution
* of the policy.
* <p>
* It executes the policy which detects and reports failures.
* Once detected, it triggers the trigger handler which takes care of
* dispatching the appropriate handler.
* <p>
* Currently executing the periodicPollPolicy.
* It executes the the polling at an interval of every 1 second.
* After every poll it checks for any failures detected.
*/
private void failureDetectorTask() {
CorfuRuntime corfuRuntime = getCorfuRuntime();
corfuRuntime.invalidateLayout();
// Fetch the latest layout view through the runtime.
safeUpdateLayout(corfuRuntime.getLayoutView().getLayout());
// Execute the failure detection policy once.
failureDetectorPolicy.executePolicy(latestLayout, corfuRuntime);
// Get the server status from the policy and check for failures.
PollReport pollReport = failureDetectorPolicy.getServerStatus();
// Analyze the poll report and trigger failure handler if needed.
analyzePollReportAndTriggerHandler(pollReport);
}
use of org.corfudb.runtime.CorfuRuntime in project CorfuDB by CorfuDB.
the class StreamIT method simpleStreamTest.
// @Test
public void simpleStreamTest() throws Exception {
Process corfuServerProcess = new CorfuServerRunner().setHost(corfuSingleNodeHost).setPort(corfuSingleNodePort).runServer();
CorfuRuntime rt = createDefaultRuntime();
rt.setCacheDisabled(true);
Random rand = new Random();
UUID streamId = CorfuRuntime.getStreamID(Integer.toString(rand.nextInt()));
IStreamView s1 = rt.getStreamsView().get(streamId);
// Verify that the stream is empty
assertThat(s1.hasNext()).isFalse();
// Generate and append random data
int entrySize = Integer.valueOf(PROPERTIES.getProperty("largeEntrySize"));
final int numEntries = 100;
byte[][] data = new byte[numEntries][entrySize];
for (int x = 0; x < numEntries; x++) {
rand.nextBytes(data[x]);
s1.append(data[x]);
}
// Read back the data and verify it is correct
for (int x = 0; x < numEntries; x++) {
ILogData entry = s1.nextUpTo(x);
byte[] tmp = (byte[]) entry.getPayload(rt);
assertThat(tmp).isEqualTo(data[x]);
}
assertThat(shutdownCorfuServer(corfuServerProcess)).isTrue();
}
Aggregations