本文整理汇总了Java中org.waveprotocol.wave.model.version.HashedVersion类的典型用法代码示例。如果您正苦于以下问题:Java HashedVersion类的具体用法?Java HashedVersion怎么用?Java HashedVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HashedVersion类属于org.waveprotocol.wave.model.version包,在下文中一共展示了HashedVersion类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testMissingDeltaKillsChannel
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Tests that the delta channel detects a gap in the op stream and
* throws an exception.
*/
public void testMissingDeltaKillsChannel() throws ChannelException {
final long initialVersion = 57;
final byte[] signature = sig(1);
final int ops = 7;
final TransformedWaveletDelta delta1 = buildServerDelta(initialVersion, ops);
checkedConnectChannel(initialVersion);
// Receive and deliver delta.
receiver.expectCommit(initialVersion);
receiver.expectDelta(delta1);
receiveUpdateOnConnectedChannel(delta1, HashedVersion.of(initialVersion, signature));
// Receive delta with a version number too high.
final TransformedWaveletDelta delta2 = buildServerDelta(initialVersion + ops + 1, 1);
try {
receiveUpdateOnConnectedChannel(delta2, HashedVersion.of(initialVersion, signature));
fail("Expected a ChannelException");
} catch (ChannelException expected) {
}
receiver.checkExpectationsSatisfied();
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:27,
代码来源:WaveletDeltaChannelImplTest.java
示例2: testReconnectWhereAnAckWasNotCommittedCanBeRecovered
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Check that the client sends the correct last known signatures.
*/
public void testReconnectWhereAnAckWasNotCommittedCanBeRecovered() throws Exception {
final int initialVersion = 42;
connectChannel(initialVersion, SIG1);
// Send op and expect an Ack.
byte[] signature43 = SIG2;
byte[] signature44 = SIG3;
sendAndCheckRandomOp(operationChannel, 42, SIG1);
operationChannel.onAck(1, HashedVersion.of(43, signature43));
// Send another op and expect an Ack.
WaveletDelta delta2 = sendAndCheckRandomOp(operationChannel, 43, signature43);
operationChannel.onAck(1, HashedVersion.of(44, signature44));
// send commit for first Ack.
operationChannel.onCommit(43);
// Check that we reconnect, the server went down and has a LCV of 43.
// Channel will resend delta2.
reconnectChannel(43, signature43, 43, signature43, null, delta2);
deltaChannel.checkExpectationsSatisfied();
checkExpectationsSatisfied();
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:25,
代码来源:OperationChannelImplTest.java
示例3: testReconnectionFailure
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Tests reconnection where the server does not provide a matching
* signature. Expect failure.
*/
public void testReconnectionFailure() throws ChannelException {
final int initialVersion = 42;
final byte[] initialSignature = SIG1;
connectChannel(initialVersion, initialSignature);
// Simulate failure
operationChannel.reset();
// Server presents unknown reconnect version
final HashedVersion reconnectVersion = HashedVersion.of(66, SIG2);
try {
operationChannel.onConnection(reconnectVersion, reconnectVersion, null, Collections.EMPTY_LIST);
fail("Should have thrown ChannelException");
} catch (ChannelException expected) {
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:22,
代码来源:OperationChannelImplTest.java
示例4: open
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Opens a delta store based state.
*
* The executor must ensure that only one thread executes at any time for each
* state instance.
*/
@Timed
public void open() throws WaveletStateException {
writeLock.lock();
try {
Preconditions.checkArgument(deltaAccess == null, "Delta state already opened");
versionZero = HASH_FACTORY.createVersionZero(waveletName);
try {
deltaAccess = deltaStore.open(waveletName);
} catch (PersistenceException ex) {
throw new WaveletStateException(ex);
}
HashedVersion endVersion = deltaAccess.getLastModifiedVersion();
if (endVersion != null) {
lastModifiedVersion = endVersion;
lastModifiedTime = deltaAccess.getLastModifiedTime();
} else {
lastModifiedVersion = versionZero;
}
lastPersistedVersion = deltaAccess.getLastModifiedVersion();
} finally {
writeLock.unlock();
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:30,
代码来源:DeltaWaveletStateImpl.java
示例5: writeBlock
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
private static Block writeBlock(BlockAccess wavelet, String blockId,
HashedVersion startVersion, HashedVersion endVersion, boolean finish) throws PersistenceException {
Block block = BlockImpl.create(blockId);
WaveletOperationContext context = new WaveletOperationContext(USER, 1234, endVersion.getVersion(), endVersion);
block.writeSegmentOperation(new SegmentOperationImpl(new AddParticipant(context, USER)));
Fragment fragment = block.createFragment(SegmentId.PARTICIPANTS_ID, false);
Segment segment = mock(Segment.class);
when(segment.getSegmentId()).thenReturn(SegmentId.PARTICIPANTS_ID);
fragment.setSegment(segment);
VersionNode node = new VersionNodeImpl();
node.setVersionInfo(new VersionInfoImpl(startVersion.getVersion(), USER, 0));
fragment.writeVersionNode(node);
node = new VersionNodeImpl();
node.setVersionInfo(new VersionInfoImpl(endVersion.getVersion(), USER, 0));
fragment.writeVersionNode(node);
if (finish) {
fragment.finish(node.getVersion());
}
wavelet.writeBlock(block);
return block;
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:22,
代码来源:BlockStoreTestBase.java
示例6: testCannotCreateDuplicatedWavelet
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
public void testCannotCreateDuplicatedWavelet() throws Exception {
WaveViewDataImpl impl = WaveViewDataImpl.create(WAVE_ID);
ObservableWaveletData.Factory<ObservableWaveletData> dataFactory =
new ObservableWaveletData.Factory<ObservableWaveletData>() {
@Override
public ObservableWaveletData create(ReadableWaveletData data) {
ObservableWaveletData n = EMPTY_DATA_FACTORY.create(data);
return n;
}
};
impl.addWavelet(dataFactory.create(
new EmptyWaveletSnapshot(WAVE_ID, WAVELET_IDS[0], CREATOR, HashedVersion.unsigned(0),
CREATE_TIMESTAMP)));
try {
impl.addWavelet(dataFactory.create(
new EmptyWaveletSnapshot(WAVE_ID, WAVELET_IDS[0], CREATOR, HashedVersion.unsigned(0),
CREATE_TIMESTAMP)));
fail("Exception expected");
} catch (IllegalArgumentException e) {
// expected an exception
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:26,
代码来源:WaveViewDataImplTest.java
示例7: startSynchronization
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Timed
@Override
public IndexingState startSynchronization(DeltaWaveletState deltaState, Executor executor) throws WaveletStateException {
writeLock.lock();
try {
if (lastModifiedVersion.getVersion() > deltaState.getLastModifiedVersion().getVersion()) {
LOG.warning("Segments version " + lastModifiedVersion
+ " is larger then deltas version " + deltaState.getLastModifiedVersion().getVersion()
+ " - rebuild segment store");
return startRemaking(deltaState, executor);
} else if (lastModifiedVersion.getVersion() < deltaState.getLastModifiedVersion().getVersion()) {
LOG.warning("Segments version " + lastModifiedVersion
+ " is less then deltas version " + deltaState.getLastModifiedVersion().getVersion()
+ " - update segment store");
HashedVersion startVersion = deltaState.getHashedVersion(lastModifiedVersion.getVersion());
segmentCache.removeWavelet(waveletName);
startIndexing(deltaState, startVersion, deltaState.getLastModifiedVersion(), executor);
return indexingState;
} else {
lastModifiedVersion = deltaState.getLastModifiedVersion();
return IndexingState.NO_INDEXING;
}
} finally {
writeLock.unlock();
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:27,
代码来源:SegmentWaveletStateImpl.java
示例8: getDeltas
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
private void getDeltas(OperationContext context, WaveletName waveletName,
ParticipantId participant, HashedVersion fromVersion, HashedVersion toVersion,
RawDeltasListener listener) throws InvalidRequestException {
final List<byte[]> deltaBytes = new LinkedList<byte[]>();
final AtomicReference<HashedVersion> version = new AtomicReference<HashedVersion>();
final AtomicInteger length = new AtomicInteger(0);
context.getDeltas(waveletName, participant, fromVersion, toVersion,
new ThrowableReceiver<WaveletDeltaRecord, InvalidRequestException>() {
@Override
public boolean put(WaveletDeltaRecord delta) throws InvalidRequestException {
ProtocolWaveletDelta protoDelta = OperationSerializer.serialize(delta.getTransformedDelta());
byte[] bytes = protoDelta.toByteArray();
deltaBytes.add(bytes);
version.set(delta.getResultingVersion());
return length.addAndGet(bytes.length) < GET_HISTORY_BYTES_LENGTH_LIMIT;
}
});
listener.onSuccess(deltaBytes, OperationSerializer.serialize(version.get()).toByteArray());
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:20,
代码来源:ExportDeltasService.java
示例9: applyDeltas
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Timed
void applyDeltas(final DeltaWaveletState deltaState,
final HashedVersion fromVersion, final HashedVersion toVersion) {
try {
deltaState.getDeltaHistory(fromVersion, toVersion,
new ThrowableReceiver<WaveletDeltaRecord, WaveletStateException>(){
@Override
public boolean put(WaveletDeltaRecord delta) throws WaveletStateException {
appendDelta(delta);
indexingState.setCurrentVersion(delta.getResultingVersion().getVersion());
return true;
}
});
} catch (WaveletStateException ex) {
LOG.severe("Indexing exception of wavelet " + waveletName.toString(), ex);
indexingState.setException(ex);
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:20,
代码来源:SegmentWaveletStateImpl.java
示例10: prepareWavelet
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
private void prepareWavelet(WaveletName waveletName) throws PersistenceException, IOException {
DeltaStore.DeltaAccess access = store.open(waveletName);
// Get all deltas from last version to initial version (0): reverse order
HashedVersion deltaResultingVersion = access.getLastModifiedVersion();
// Deltas
LinkedList<WaveletDeltaRecord> deltaRecords = new LinkedList<>();
while (deltaResultingVersion != null && deltaResultingVersion.getVersion() != 0) {
WaveletDeltaRecord deltaRecord = access.getDeltaByEndVersion(deltaResultingVersion.getVersion());
deltaRecords.addLast(deltaRecord);
// get the previous delta, this is the appliedAt
deltaResultingVersion = deltaRecord.getAppliedAtVersion();
}
while (!deltaRecords.isEmpty()) {
prepareDeltaRecord(deltaRecords.pollLast());
}
log(1, "Prepared " + deltaRecords.size() + " delta(s)");
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:20,
代码来源:DeltaPreparator.java
示例11: testAppendDeltas
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
public void testAppendDeltas() throws Exception {
addCarolOp.apply(waveletData);
HashedVersion hashedVersionTwo = HashedVersion.unsigned(2);
TransformedWaveletDelta delta = new TransformedWaveletDelta(ALEX, hashedVersionTwo, 0L,
Arrays.asList(addCarolOp));
wavelet.appendDeltas(waveletData, DeltaSequence.of(delta));
ReadableWaveletData firstSnapshot = wavelet.getSnapshotBeforeDeltas();
assertFalse("Bob should not be a participant", firstSnapshot.getParticipants().contains(BOB));
assertEquals(hashedVersionTwo, wavelet.getVersionAfterDeltas());
ReadableWaveletData latestSnapshot = wavelet.getSnapshotAfterDeltas();
assertNotSame("A copy of the waveletdata must be made", waveletData, latestSnapshot);
Collection<ParticipantId> participants =
Collections.unmodifiableCollection(Arrays.asList(BOB, CAROL));
assertTrue("Bob and Carol should be participating",
latestSnapshot.getParticipants().containsAll(participants));
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:21,
代码来源:WaveletAndDeltasTest.java
示例12: maybeTransformSubmittedDelta
点赞 3
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Transform a wavelet delta if it has been submitted against a different head (currentVersion).
* Must be called with write lock held.
*
* @param delta to possibly transform
* @return the transformed delta and the version it was applied at
* (the version is the current version of the wavelet, unless the delta is
* a duplicate in which case it is the version at which it was originally
* applied)
* @throws InvalidHashException if submitting against same version but different hash
* @throws OperationException if transformation fails
*/
protected WaveletDelta maybeTransformSubmittedDelta(WaveletDelta delta)
throws InvalidHashException, OperationException, TransformException, WaveletStateException {
HashedVersion targetVersion = delta.getTargetVersion();
HashedVersion currentVersion = getLastModifiedVersion();
if (targetVersion.equals(currentVersion)) {
// Applied version is the same, we're submitting against head, don't need to do OT
return delta;
} else {
// Not submitting against head, we need to do OT, but check the versions really are different
if (targetVersion.getVersion() == currentVersion.getVersion()) {
LOG.warning("Mismatched hash, expected " + currentVersion + ") but delta targets (" +
targetVersion + ")");
throw new InvalidHashException(currentVersion, targetVersion);
} else {
DeltaHistory history = new WaveletDeltaHistory(deltaStateAccessor.get());
WaveletDelta transformedDelta = ConcurrencyControlCore.onClientDelta(delta, history);
LOG.info("OT transformed " +
delta.getTargetVersion().getVersion() + "-" + delta.getResultingVersion() + " -> " +
transformedDelta.getTargetVersion().getVersion() + "-" + transformedDelta.getResultingVersion());
return transformedDelta;
}
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:36,
代码来源:WaveletContainerImpl.java
示例13: createEmptyRobotWavelet
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Creates a new empty robot wavelet data.
*
* @param participant the wavelet creator.
* @param waveletName the wavelet name.
*/
public static RobotWaveletData createEmptyRobotWavelet(ParticipantId participant,
WaveletName waveletName) {
HashedVersion hashedVersionZero = HASH_FACTORY.createVersionZero(waveletName);
ObservableWaveletData emptyWavelet =
WaveletDataUtil.createEmptyWavelet(waveletName, participant, hashedVersionZero,
System.currentTimeMillis());
RobotWaveletData newWavelet = new RobotWaveletData(emptyWavelet, hashedVersionZero);
return newWavelet;
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:16,
代码来源:RobotsUtil.java
示例14: exportDeltas
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
private void exportDeltas(WaveId waveId, WaveletId waveletId, ProtocolHashedVersion lastVersion,
Set<AttachmentId> attachmentIds) throws IOException {
HashedVersion zeroVersion = HASH_FACTORY.createVersionZero(WaveletName.of(waveId, waveletId));
ProtocolHashedVersion version = OperationSerializer.serialize(zeroVersion);
for (int fetchNum = 0; version.getVersion() != lastVersion.getVersion(); fetchNum++) {
Console.print(" getting deltas from version " + version.getVersion() + " ...");
final List<byte[]> deltas = Lists.newArrayList();
final AtomicReference<byte[]> targetVersion = new AtomicReference<byte[]>();
api.exportRawDeltas(waveId, waveletId,
version.toByteArray(), lastVersion.toByteArray(), rpcServerUrl,
new RawDeltasListener() {
@Override
public void onSuccess(List<byte[]> rawDeltas, byte[] rawTargetVersion) {
deltas.addAll(rawDeltas);
targetVersion.set(rawTargetVersion);
}
@Override
public void onFailure(String message) {
Console.error(search);
}
});
if (deltas.isEmpty()) {
Console.println(" empty response");
continue;
}
version = ProtocolHashedVersion.parseFrom(targetVersion.get());
Console.println(" Ok, got to version " + version.getVersion());
writeDeltasToFile(waveId, waveletId, deltas, fetchNum);
for (byte[] delta : deltas) {
attachmentIds.addAll(DeltaParser.getAttachemntIds(ProtocolWaveletDelta.parseFrom(delta)));
}
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:36,
代码来源:WaveExport.java
示例15: deserializeSnapshot
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Deserializes the snapshot contained in the {@link ProtocolUpdate}
* into a {@link ObservableWaveletData}.
*
* @param snapshot the {@link WaveletSnapshot} to deserialize.
* @param version the version of the wavelet after all deltas have been
* applied.
* @param waveletName the name of the wavelet contained in the update.
* @throws OperationException if the ops in the snapshot can not be applied.
*/
public static ObservableWaveletData deserializeSnapshot(
WaveletSnapshot snapshot, ProtocolHashedVersion version, WaveletName waveletName)
throws OperationException {
// TODO(ljvderijk): This method does too many steps to get to the
// ObservableWaveletData.
// We need something simpler when operations and the protocol have been
// edited.
// Creating a CoreWaveletData because the current protocol lacks the
// meta-data required to construct an ObservableWaveletData directly.
// But this results in unnecessary object creation and copies.
CoreWaveletData coreWavelet =
new CoreWaveletDataImpl(waveletName.waveId, waveletName.waveletId);
Preconditions.checkArgument(snapshot.getParticipantIdCount() > 0);
// Have to add a single participant for the copying to complete without a
// NPE.
coreWavelet.addParticipant(ParticipantId.ofUnsafe(snapshot.getParticipantId(0)));
for (DocumentSnapshot document : snapshot.getDocumentList()) {
DocOp op =
CoreWaveletOperationSerializer.deserialize(document.getDocumentOperation());
coreWavelet.modifyDocument(document.getDocumentId(), op);
}
HashedVersion hashedVersion = CoreWaveletOperationSerializer.deserialize(version);
ObservableWaveletData immutableWaveletData =
DataUtil.fromCoreWaveletData(coreWavelet, hashedVersion, SchemaCollection.empty());
ObservableWaveletData wavelet = WaveletDataUtil.copyWavelet(immutableWaveletData);
for (String participant : snapshot.getParticipantIdList()) {
wavelet.addParticipant(new ParticipantId(participant), null);
}
return wavelet;
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:48,
代码来源:CoreWaveletOperationSerializer.java
示例16: getLastModifiedVersionAndTime
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public Pair<HashedVersion, Long> getLastModifiedVersionAndTime(WaveletName waveletName) throws WaveServerException {
Preconditions.checkState(initialized, "Wave server not yet initialized");
WaveletContainer wavelet = getWavelet(waveletName);
if (wavelet == null) {
LOG.info("client requested version for non-existent wavelet: " + waveletName);
return null;
} else {
return wavelet.getLastModifiedVersionAndTime();
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:12,
代码来源:WaveServerImpl.java
示例17: submit
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Timed
@Override
public void submit(RpcController controller, ClientServer.SubmitDeltaRequest request,
final RpcCallback<ClientServer.SubmitDeltaResponse> done) {
ParticipantId loggedInUser = asBoxController(controller).getLoggedInUser();
frontend.submitRequest(loggedInUser, request.getChannelId(), request.getDelta(),
new SubmitRequestCallback() {
@Override
public void onSuccess(int operationsApplied,
HashedVersion hashedVersionAfterApplication, long applicationTimestamp) {
done.run(SubmitDeltaResponse.newBuilder()
.setStatus(ResponseStatus.newBuilder().setCode(ResponseCode.OK))
.setOperationsApplied(operationsApplied)
.setHashedVersionAfterApplication(OperationSerializer.serialize(hashedVersionAfterApplication))
.setTimestampAfterApplication(applicationTimestamp)
.build());
}
@Override
public void onFailure(ReturnCode responseCode, String error) {
ResponseStatus status = ResponseStatus.newBuilder()
.setCode(deserialize(responseCode)).setFailureReason(error).build();
done.run(SubmitDeltaResponse.newBuilder()
.setStatus(status).build());
}
});
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:28,
代码来源:WaveClientServerImpl.java
示例18: getDeltaHistory
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public void getDeltaHistory(HashedVersion startVersion, HashedVersion endVersion,
ThrowableReceiver<WaveletDeltaRecord, WaveletStateException> receiver) throws WaveletStateException {
HashedVersion version = startVersion;
while (!version.equals(endVersion)) {
WaveletDeltaRecord delta = history.get(version);
if (delta == null || !receiver.put(delta)) {
break;
}
version = delta.getResultingVersion();
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:13,
代码来源:SimpleDeltaHistory.java
示例19: create
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public OpBasedWavelet create(WaveId waveId, WaveletId waveletId, ParticipantId creator) {
long now = System.currentTimeMillis();
HashedVersion v0 = HashedVersion.unsigned(0);
ObservableWaveletData waveData = holderFactory
.create(new EmptyWaveletSnapshot(waveId, waveletId, creator, v0, now));
lastContextFactory = new MockWaveletOperationContextFactory().setParticipantId(author);
lastAuthoriser = new MockParticipationHelper();
SilentOperationSink<WaveletOperation> executor =
Executor.<WaveletOperation, WaveletData>build(waveData);
SilentOperationSink<WaveletOperation> out = new VersionIncrementingSink(waveData, sink);
return new OpBasedWavelet(waveId, waveData, lastContextFactory, lastAuthoriser, executor, out);
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:14,
代码来源:OpBasedWaveletFactory.java
示例20: waveletCommitted
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Timed
@Override
public void waveletCommitted(WaveletName waveletName, HashedVersion version) {
for (WaveletSubscription subscription : subscriptions.getSubscriptions(waveletName)) {
subscription.onCommit(version);
if (!subscription.isUnsubscribeStarted() && subscription.unsubscribe()) {
subscriptions.unsubscribe(subscription);
}
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:11,
代码来源:ClientFrontendImpl.java
示例21: doSubmitSuccess
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/** Reports a submit success with the specified resulting version and application timestamp */
public void doSubmitSuccess(String channelId, HashedVersion resultingVersion,
long applicationTimestamp) {
SubmitRecord record = submitRecords.remove(channelId);
if (record != null) {
record.listener.onSuccess(record.operations, resultingVersion, applicationTimestamp);
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:9,
代码来源:FakeClientFrontend.java
示例22: serialize
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Serializes a transformed delta as a {@link ProtocolWaveletDelta}.
*
* The target version of the result does not have an accompanying hash;
* server delta hashes are redundant in the client/server protocol.
*
* @param delta to serialize
* @return serialized protocol buffer wavelet delta
*/
public static ProtocolWaveletDelta serialize(TransformedWaveletDelta delta) {
ProtocolWaveletDelta.Builder protobufDelta = ProtocolWaveletDelta.newBuilder();
for (WaveletOperation waveletOp : delta) {
protobufDelta.addOperation(serialize(waveletOp));
}
protobufDelta.setAuthor(delta.getAuthor().getAddress());
protobufDelta.setHashedVersion(serialize(HashedVersion.unsigned(delta.getAppliedAtVersion())));
return protobufDelta.build();
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:21,
代码来源:OperationSerializer.java
示例23: getHashedVersionAppliedAt
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Inspects the given applied delta to determine the {@code HashedVersion} it
* was applied at.
* This may require looking at the contained {@code ProtocolWaveletDelta}.
*
* @param appliedDeltaBytes to inspect
* @return hashed version the delta was applied at
* @throws InvalidProtocolBufferException if the contained
* {@code ProtocolWaveletDelta} is invalid
* (is only inspected if the applied delta has the hashed version set)
*/
public static HashedVersion getHashedVersionAppliedAt(
ByteStringMessage<ProtocolAppliedWaveletDelta> appliedDeltaBytes)
throws InvalidProtocolBufferException {
ProtocolAppliedWaveletDelta appliedDelta = appliedDeltaBytes.getMessage();
return OperationSerializer.deserialize(
// If the delta was transformed, the version it was actually applied at is specified
// in the top-level message, otherwise we take if from the original signed delta.
appliedDelta.hasHashedVersionAppliedAt()
? appliedDelta.getHashedVersionAppliedAt()
: ProtocolWaveletDelta.parseFrom(appliedDelta.getSignedOriginalDelta().getDelta())
.getHashedVersion());
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:24,
代码来源:AppliedDeltaUtil.java
示例24: getLastModifiedVersionAndTime
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public Pair<HashedVersion, Long> getLastModifiedVersionAndTime() {
readLock.lock();
try {
return Pair.of(getLastModifiedVersion(), getLastModifiedTime());
} finally {
readLock.unlock();
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:10,
代码来源:DeltaWaveletStateImpl.java
示例25: onConnection
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public void onConnection(HashedVersion connectVersion, HashedVersion lastModifiedVersion, HashedVersion lastCommittedVersion, HashedVersion unacknowledgedDeltaVersion, List<WaveletOperation> operations) throws ChannelException {
Object[] expected = expectations.remove();
assertEquals(expected[0], Method.CONNECTION);
assertEquals(expected[1], operations);
assertEquals(expected[2], connectVersion);
assertEquals(expected[3], lastModifiedVersion);
assertEquals(expected[4], lastCommittedVersion);
assertEquals(expected[5], unacknowledgedDeltaVersion);
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:11,
代码来源:MockWaveletDeltaChannel.java
示例26: setUp
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public void setUp() {
WaveId waveId = WaveId.of("example.com", "c+123");
WaveletId waveletId = WaveletId.of("example.com", IdConstants.CONVERSATION_ROOT_WAVELET);
wavelet = new WaveletDataImpl(waveletId, CREATOR, 0L, 0L,
HashedVersion.unsigned(0), 0L, waveId,
BasicFactories.pluggableMutableDocumentFactory());
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:9,
代码来源:AddParticipantTest.java
示例27: testProcessSendsNoBundleWhenNoEvents
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
public void testProcessSendsNoBundleWhenNoEvents() throws Exception {
enqueueEmptyWavelet();
robot.run();
// Verify that the robot was not called or any operations where processed
verify(connector, never()).sendMessageBundle(
any(EventMessageBundle.class), eq(robot), any(ProtocolVersion.class));
verify(operationApplicator, never()).applyOperations(anyListOf(OperationRequest.class),
any(ReadableWaveletData.class), any(HashedVersion.class), eq(ACCOUNT));
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:10,
代码来源:RobotTest.java
示例28: createVersionUpdateOp
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public VersionUpdateOp createVersionUpdateOp(long segmentVersion, HashedVersion hashedVersion) {
if (blipOp.updatesBlipMetadata(blipId)) {
return new VersionUpdateOp(context.getCreator(), blipId, segmentVersion, hashedVersion);
} else {
return new VersionUpdateOp(context.getCreator(), null, -1, hashedVersion);
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:9,
代码来源:WaveletBlipOperation.java
示例29: getDeltaHistory
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public void getDeltaHistory(HashedVersion startVersion, HashedVersion endVersion,
final ThrowableReceiver<WaveletDeltaRecord, WaveletStateException> receiver) throws WaveletStateException {
checkOpened();
readDeltasInRange(startVersion, endVersion, new ThrowableReceiver<WaveletDeltaRecord, WaveletStateException>() {
@Override
public boolean put(WaveletDeltaRecord record) throws WaveletStateException {
return receiver.put(record);
}
});
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:13,
代码来源:DeltaWaveletStateImpl.java
示例30: setHashedVersion
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
final public HashedVersion setHashedVersion(HashedVersion newHashedVersion) {
if (!hashedVersion.equals(newHashedVersion)) {
HashedVersion oldHashedVersion = hashedVersion;
hashedVersion = newHashedVersion;
listenerManager.onHashedVersionChanged(oldHashedVersion, newHashedVersion);
return oldHashedVersion;
} else {
return hashedVersion;
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:12,
代码来源:AbstractWaveletData.java
示例31: getDeltaRecordByEndVersion
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public WaveletDeltaRecord getDeltaRecordByEndVersion(HashedVersion endVersion) {
checkOpened();
long version = endVersion.getVersion();
try {
return deltaAccess.getDeltaByEndVersion(version);
} catch (IOException e) {
throw new RuntimeIOException(new IOException(format("Version : %d", version), e));
}
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:11,
代码来源:DeltaWaveletStateImpl.java
示例32: reconnect
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Reconnects with the known versions provided by stacklets.
*
* @param exception The exception that caused the reconnection
*/
private void reconnect(final Map<WaveletId, Set<SegmentId>> knownSegmentIds) {
Preconditions.checkState(state != State.CONNECTED, "Cannot connect already-connected channel");
logger.trace().log("Reconnecting multiplexer");
state = State.RECONNECTING;
// NOTE(zdwang): don't clear this as we'll lose wavelets if we've never
// been connected. This is a reminder.
// onConnected.clear();
// Reset each stacklet, collecting the reconnect versions.
final Map<WaveletId, List<HashedVersion>> knownWavelets = CollectionUtils.newHashMap();
final Map<WaveletId, WaveletDelta> unacknowledgedDeltas = CollectionUtils.newHashMap();
for (final WaveletId waveletId : channels.keySet()) {
Stacklet stacklet = channels.get(waveletId);
knownWavelets.put(waveletId, stacklet.getOperationChannel().getReconnectVersions());
if (stacklet.getOperationChannel().getUnacknowledgedDelta() != null) {
unacknowledgedDeltas.put(waveletId, stacklet.getOperationChannel().getUnacknowledgedDelta());
}
}
// Run the connect part in the scheduler
scheduler.schedule(new Scheduler.Command() {
@Override
public void execute() {
connect(knownWavelets, knownSegmentIds, unacknowledgedDeltas.isEmpty() ? null : unacknowledgedDeltas);
}
});
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:35,
代码来源:OperationChannelMultiplexerImpl.java
示例33: hasSignature
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
@Override
public boolean hasSignature(HashedVersion signature) {
HashedVersion found = signatures.get(signature.getVersion());
if (found == null) {
return false;
}
return found.equals(signature);
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:9,
代码来源:SimpleDeltaHistory.java
示例34: lookupCached
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* @return An entry keyed by a hashed version with the given version number,
* if any, otherwise null.
*/
static <T> Map.Entry<HashedVersion, T> lookupCached(NavigableMap<HashedVersion, T> map,
long version) {
// Smallest key with version number >= version.
HashedVersion key = HashedVersion.unsigned(version);
Map.Entry<HashedVersion, T> entry = map.ceilingEntry(key);
return (entry != null && entry.getKey().getVersion() == version) ? entry : null;
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:12,
代码来源:DeltaWaveletStateImpl.java
示例35: testMultipleChannelsAreIndependent
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
public void testMultipleChannelsAreIndependent() throws ChannelException {
final ChannelInfo chInfo1 = new ChannelInfo(WAVELET_ID_1, 1, SIG1);
final ChannelInfo chInfo2 = new ChannelInfo(WAVELET_ID_2, 20, SIG2);
MuxInfo muxInfo = openMux(chInfo1, chInfo2);
// Check channels receive ops independently.
final int serverOps1 = 5;
ConnectedChannel ch1 = muxInfo.channels.get(0);
ConnectedChannel ch2 = muxInfo.channels.get(1);
checkReceiveDelta(muxInfo.viewListener, ch1.channel, ch1.listener,
WAVELET_ID_1, chInfo1.initialVersion, serverOps1, SIG4);
ch2.listener.checkOpsReceived(0);
final int serverOps2 = 7;
checkReceiveDelta(muxInfo.viewListener, ch2.channel, ch2.listener, WAVELET_ID_2, chInfo2.initialVersion,
serverOps2, SIG5);
ch1.listener.checkOpsReceived(0);
// Check channels send ops independently.
checkSendDelta(viewChannel, ch1.channel, HashedVersion.of(chInfo1.initialVersion + serverOps1, SIG4),
WAVELET_ID_1);
checkSendDelta(viewChannel, ch2.channel, HashedVersion.of(chInfo2.initialVersion + serverOps2, SIG5),
WAVELET_ID_2);
// Check acks are received independently.
final byte[] ackSignature1 = SIG6;
final byte[] ackSignature2 = SIG7;
final long ackVersion1 = chInfo1.initialVersion + serverOps1 + 1;
final long ackVersion2 = chInfo2.initialVersion + serverOps2 + 1;
checkAckDelta(viewChannel, ch1.channel, ch1.listener, 1, ackVersion1, ackSignature1);
checkAckDelta(viewChannel, ch2.channel, ch2.listener, 1, ackVersion2, ackSignature2);
viewChannel.checkExpectationsSatisified();
muxListener.verifyNoMoreInteractions();
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:37,
代码来源:OperationChannelMultiplexerImplTest.java
示例36: AbstractWaveletData
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Creates a new wavelet.
*
* @param id id of the wavelet
* @param creator creator of the wavelet
* @param creationTime timestamp of wavelet creation
* @param version initial version of the wavelet
* @param hashedVersion initial distinct server version of the wavelet
* @param lastModifiedTime initial last-modified time for the wavelet
* @param waveId id of the wave containing the wavelet
* @param contentFactory factory for creating new documents
*/
protected AbstractWaveletData(WaveletId id, ParticipantId creator, long creationTime,
long version, HashedVersion hashedVersion, long lastModifiedTime, WaveId waveId,
DocumentFactory<?> contentFactory) {
Preconditions.checkNotNull(id, "id cannot be null");
Preconditions.checkNotNull(waveId, "wave id cannot be null");
this.id = id;
this.creator = creator;
this.creationTime = creationTime;
this.hashedVersion = hashedVersion;
this.lastModifiedTime = lastModifiedTime;
this.waveId = waveId;
this.contentFactory = contentFactory;
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:27,
代码来源:AbstractWaveletData.java
示例37: MethodCallContext
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
public MethodCallContext(MethodCall method, WaveletId waveletId,
List<TransformedWaveletDelta> deltas, HashedVersion lastCommittedVersion) {
this.method = method;
this.waveletId = waveletId;
this.deltas = deltas;
this.fragments = null;
this.connectVersion = null;
this.lastModifiedVersion = null;
this.lastModifiedTime = 0L;
this.lastCommittedVersion = lastCommittedVersion;
this.unacknowledgedDeltaVersion = null;
this.status = null;
this.ex = null;
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:15,
代码来源:ViewChannelImplTest.java
示例38: expectedWaveletOpenCall
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
public void expectedWaveletOpenCall(WaveletId waveletId, HashedVersion connectVersion,
HashedVersion lastModifiedVersion, HashedVersion lastCommittedVersion, HashedVersion unacknowledgedDeltaVersion,
List<RawFragment> fragments) {
assertEquals(MethodCall.ON_WAVELET_OPENED, methodCalls.get(0).method);
assertEquals(waveletId, methodCalls.get(0).waveletId);
assertEquals(connectVersion, methodCalls.get(0).connectVersion);
assertEquals(lastModifiedVersion, methodCalls.get(0).lastModifiedVersion);
assertEquals(lastCommittedVersion, methodCalls.get(0).lastCommittedVersion);
assertEquals(unacknowledgedDeltaVersion, methodCalls.get(0).unacknowledgedDeltaVersion);
assertEquals(fragments, methodCalls.get(0).fragments);
methodCalls.remove(0);
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:14,
代码来源:ViewChannelImplTest.java
示例39: makeNoOpDelta
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
/**
* Builds a no-op client delta.
*/
public WaveletDelta makeNoOpDelta(HashedVersion targetVersion, long timestamp, int numOps) {
List<WaveletOperation> ops = CollectionUtils.newArrayList();
WaveletOperationContext context =
new WaveletOperationContext(author, Constants.NO_TIMESTAMP, 1);
for (int i = 0; i < numOps; ++i) {
ops.add(new NoOp(context));
}
return new WaveletDelta(author, targetVersion, ops);
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:13,
代码来源:DeltaTestUtil.java
示例40: createProtocolSignedDelta
点赞 2
import org.waveprotocol.wave.model.version.HashedVersion; //导入依赖的package包/类
private ProtocolSignedDelta createProtocolSignedDelta(ProtocolWaveletOperation operation,
HashedVersion protocolHashedVersion) {
ProtocolWaveletDelta delta = ProtocolWaveletDelta.newBuilder()
.setAuthor(AUTHOR)
.setHashedVersion(OperationSerializer.serialize(protocolHashedVersion))
.addOperation(operation)
.build();
return ProtocolSignedDelta.newBuilder()
.setDelta(delta.toByteString())
.addSignature(SIGNATURE)
.build();
}
开发者ID:jorkey,
项目名称:Wiab.pro,
代码行数:14,
代码来源:LocalWaveletContainerImplTest.java