public PaxosState(Commit promised, Commit accepted, Commit mostRecentCommit) { assert promised.key == accepted.key && accepted.key == mostRecentCommit.key; assert promised.update.metadata() == accepted.update.metadata() && accepted.update.metadata() == mostRecentCommit.update.metadata(); this.promised = promised; this.accepted = accepted; this.mostRecentCommit = mostRecentCommit; }
public PrepareResponse(boolean promised, Commit inProgressCommit, Commit mostRecentCommit) { assert inProgressCommit.key == mostRecentCommit.key; assert inProgressCommit.update.metadata() == mostRecentCommit.update.metadata(); this.promised = promised; this.mostRecentCommit = mostRecentCommit; this.inProgressCommit = inProgressCommit; }
public Mutation(ByteBuffer key, ColumnFamily cf) { this(cf.metadata().ksName, key, cf); }
public boolean apply(ColumnFamily cf) { return cfNames.contains(cf.metadata().cfName); } });
/** * Start a new super column with name {@code name}. * @param name the name for the super column */ public void newSuperColumn(ByteBuffer name) { if (!columnFamily.metadata().isSuper()) throw new IllegalStateException("Cannot add a super column to a standard column family"); currentSuperColumn = name; }
public static int calculateHintTTL(Mutation mutation) { int ttl = maxHintTTL; for (ColumnFamily cf : mutation.getColumnFamilies()) ttl = Math.min(ttl, cf.metadata().getGcGraceSeconds()); return ttl; }
private ColumnDefinition getDefinition(String name) { return cf.metadata().getColumnDefinition(new ColumnIdentifier(name, false)); }
void markDirty(Mutation mutation, int allocatedPosition) { for (ColumnFamily columnFamily : mutation.getColumnFamilies()) { // check for deleted CFS CFMetaData cfm = columnFamily.metadata(); if (cfm.isPurged()) logger.error("Attempted to write commit log entry for unrecognized column family: {}", columnFamily.id()); else ensureAtleast(cfDirty, cfm.cfId, allocatedPosition); } }
public boolean appliesTo(Composite rowPrefix, ColumnFamily current, long now) throws InvalidRequestException { CellName name = current.metadata().comparator.create(rowPrefix, column); return isSatisfiedByValue(value, current.getColumn(name), column.type, operator, now); } }
public boolean appliesTo(Composite rowPrefix, ColumnFamily current, long now) throws InvalidRequestException { CellName name = current.metadata().comparator.create(rowPrefix, column); for (ByteBuffer value : inValues) { if (isSatisfiedByValue(value, current.getColumn(name), column.type, Operator.EQ, now)) return true; } return false; } }
public LogEntry(String keyspace, ColumnFamily columnFamily, ByteBuffer rowKey, ConsistencyLevel consistencyLevel, String host, long timestamp, Collection<String> columnNames) throws Throwable { this(keyspace, rowKey, consistencyLevel, host, timestamp, columnNames); this.columnFamily = columnFamily.metadata().cfName; for (IColumn column : columnFamily.getSortedColumns()) { ColumnOperation operation = new ColumnOperation(); operation.setName(column.name()); operation.setDelete(columnFamily.isMarkedForDelete()); operations.add(operation); } }
/** * Get portion of the columns and serialize in loop while not more columns left in the row * * @param row SSTableIdentityIterator row representation with Column Family * @param key Decorated Key for the required row * @param out output stream */ private static void serializeRow(SSTableIdentityIterator row, DecoratedKey key, PrintStream out) { serializeRow(row.getColumnFamily().deletionInfo(), row, row.getColumnFamily().metadata(), key, out); }
private void validate(Collection<Mutation> tmutations) throws InvalidRequestException { for (Mutation mutation : tmutations) { QueryProcessor.validateKey(mutation.key()); for (ColumnFamily tcf : mutation.getColumnFamilies()) for (Cell cell : tcf) cell.validateFields(tcf.metadata()); } }
public CFRowAdder(ColumnFamily cf, Composite prefix, long timestamp) { this.cf = cf; this.prefix = prefix; this.timestamp = timestamp; this.ldt = (int) (System.currentTimeMillis() / 1000); // If a CQL3 table, add the row marker if (cf.metadata().isCQL3Table() && !prefix.isStatic()) cf.addColumn(new BufferCell(cf.getComparator().rowMarker(prefix), ByteBufferUtil.EMPTY_BYTE_BUFFER, timestamp)); }
public void run() { Mutation mutation = new Mutation(TRACE_KS, sessionIdBytes); ColumnFamily cells = mutation.addOrGet(CFMetaData.TraceSessionsCf); CFRowAdder adder = new CFRowAdder(cells, cells.metadata().comparator.builder().build(), FBUtilities.timestampMicros()); adder.add("coordinator", FBUtilities.getBroadcastAddress()); for (Map.Entry<String, String> entry : parameters.entrySet()) adder.addMapEntry("parameters", entry.getKey(), entry.getValue()); adder.add("request", request); adder.add("started_at", new Date(started_at)); mutateWithCatch(mutation); } });
private static PrepareCallback preparePaxos(Commit toPrepare, List<InetAddress> endpoints, int requiredParticipants, ConsistencyLevel consistencyForPaxos) throws WriteTimeoutException { PrepareCallback callback = new PrepareCallback(toPrepare.key, toPrepare.update.metadata(), requiredParticipants, consistencyForPaxos); MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_PREPARE, toPrepare, Commit.serializer); for (InetAddress target : endpoints) MessagingService.instance().sendRR(message, target, callback); callback.await(); return callback; }
protected void addColumn(Cell cell) throws IOException { if (columnFamily.metadata().isSuper()) { if (currentSuperColumn == null) throw new IllegalStateException("Trying to add a cell to a super column family, but no super cell has been started."); cell = cell.withUpdatedName(columnFamily.getComparator().makeCellName(currentSuperColumn, cell.name().toByteBuffer())); } columnFamily.addColumn(cell); }
public void run() { Mutation mutation = new Mutation(TRACE_KS, sessionIdBytes); ColumnFamily cells = mutation.addOrGet(CFMetaData.TraceSessionsCf); CFRowAdder adder = new CFRowAdder(cells, cells.metadata().comparator.builder().build(), FBUtilities.timestampMicros()); adder.add("duration", elapsed); mutateWithCatch(mutation); } });
public void runMayThrow() { Mutation mutation = new Mutation(Tracing.TRACE_KS, sessionIdBytes); ColumnFamily cells = mutation.addOrGet(CFMetaData.TraceEventsCf); CFRowAdder adder = new CFRowAdder(cells, cells.metadata().comparator.make(UUIDGen.getTimeUUID()), FBUtilities.timestampMicros()); adder.add("activity", message); adder.add("source", FBUtilities.getBroadcastAddress()); if (elapsed >= 0) adder.add("source_elapsed", elapsed); adder.add("thread", threadName); Tracing.mutateWithCatch(mutation); } });