@Override public byte[] persistValue() { byte[] bytes = value.persistToBytes(); return CompressionUtils.compress(bytes, Compression.NONE); }
void moveToComplete(TableReference table, int id) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); SweepTableIdentifier oldValue = SweepTableIdentifier.pending(id); SweepTableIdentifier newValue = SweepTableIdentifier.identified(id); CheckAndSetRequest request = CheckAndSetRequest.singleCell( NAME_TO_ID, cell, oldValue.persistToBytes(), newValue.persistToBytes()); try { kvs.checkAndSet(request); } catch (CheckAndSetException e) { SweepTableIdentifier actual = currentMapping(table).get(); checkState(newValue.equals(actual), "Unexpectedly we state changed from pending(id) to " + "not(identified(id)) after identifying id as the correct value"); } }
void storeAsPending(TableReference table, int lastAttempt, int thisAttempt) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); byte[] oldValue = SweepTableIdentifier.pending(lastAttempt).persistToBytes(); byte[] newValue = SweepTableIdentifier.pending(thisAttempt).persistToBytes(); CheckAndSetRequest cas = CheckAndSetRequest.singleCell(NAME_TO_ID, cell, oldValue, newValue); try { kvs.checkAndSet(cas); } catch (CheckAndSetException e) { // ignored; we're already spinning } }
SweepTableIdentifier storeAsPending(TableReference table, int nextId) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); SweepTableIdentifier newValue = SweepTableIdentifier.pending(nextId); CheckAndSetRequest cas = CheckAndSetRequest.newCell(NAME_TO_ID, cell, newValue.persistToBytes()); try { kvs.checkAndSet(cas); return newValue; } catch (CheckAndSetException e) { return currentMapping(table).get(); } }
@Override public byte[] persistValue() { byte[] bytes = value.persistToBytes(); return CompressionUtils.compress(bytes, Compression.NONE); }
void moveToComplete(TableReference table, int id) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); SweepTableIdentifier oldValue = SweepTableIdentifier.pending(id); SweepTableIdentifier newValue = SweepTableIdentifier.identified(id); CheckAndSetRequest request = CheckAndSetRequest.singleCell( NAME_TO_ID, cell, oldValue.persistToBytes(), newValue.persistToBytes()); try { kvs.checkAndSet(request); } catch (CheckAndSetException e) { SweepTableIdentifier actual = currentMapping(table).get(); checkState(newValue.equals(actual), "Unexpectedly we state changed from pending(id) to " + "not(identified(id)) after identifying id as the correct value"); } }
void storeAsPending(TableReference table, int lastAttempt, int thisAttempt) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); byte[] oldValue = SweepTableIdentifier.pending(lastAttempt).persistToBytes(); byte[] newValue = SweepTableIdentifier.pending(thisAttempt).persistToBytes(); CheckAndSetRequest cas = CheckAndSetRequest.singleCell(NAME_TO_ID, cell, oldValue, newValue); try { kvs.checkAndSet(cas); } catch (CheckAndSetException e) { // ignored; we're already spinning } }
SweepTableIdentifier storeAsPending(TableReference table, int nextId) { SweepNameToIdRow row = SweepNameToIdRow.of(table.getQualifiedName()); Cell cell = Cell.create(row.persistToBytes(), SweepNameToIdNamedColumn.ID.getShortName()); SweepTableIdentifier newValue = SweepTableIdentifier.pending(nextId); CheckAndSetRequest cas = CheckAndSetRequest.newCell(NAME_TO_ID, cell, newValue.persistToBytes()); try { kvs.checkAndSet(cas); return newValue; } catch (CheckAndSetException e) { return currentMapping(table).get(); } }