@Override public Object getMetaData(Column<ByteBuffer> element, EntryMetaData meta) { switch(meta) { case TIMESTAMP: return element.getTimestamp(); case TTL: return element.getTtl(); default: throw new UnsupportedOperationException("Unsupported meta data: " + meta); } } }
return new Shard(column.getName(), column.getTimestamp(), column.getBooleanValue());
@Override public long getClock() { return astyanaxColumn.getTimestamp(); } }
@Override public long getTimestamp() { return _oldColumn.getTimestamp(); }
@Override public long getTimestamp() { return _oldColumn.getTimestamp(); }
@Override public Object getMetaData(Column<ByteBuffer> element, EntryMetaData meta) { switch(meta) { case TIMESTAMP: return element.getTimestamp(); case TTL: return element.getTtl(); default: throw new UnsupportedOperationException("Unsupported meta data: " + meta); } } }
@Override public Object getMetaData(Column<ByteBuffer> element, EntryMetaData meta) { switch(meta) { case TIMESTAMP: return element.getTimestamp(); case TTL: return element.getTtl(); default: throw new UnsupportedOperationException("Unsupported meta data: " + meta); } } }
@Override public synchronized Boolean apply(Row<K, C> row) { long size = 0; for (Column<C> column : row.getColumns()) { size += column.getRawName().limit() + column.getByteBufferValue().limit(); } StringBuilder sb = new StringBuilder(); sb.append(String.format("- row: '%s' size: '%dl' count: '%dl' \n", row.getKey(), size, row.getColumns().size())); if (showColumns) { for (Column<C> column : row.getColumns()) { sb.append(String.format(" '%s' (ts='%dl', ttl='%d')\n", column.getName(), column.getTimestamp(), column.getTtl())); } } try { out.write(sb.toString().getBytes()); } catch (IOException e) { } return true; }
@Override public synchronized Boolean apply(Row<K, C> row) { long size = 0; for (Column<C> column : row.getColumns()) { size += column.getRawName().limit() + column.getByteBufferValue().limit(); } StringBuilder sb = new StringBuilder(); sb.append(String.format("- row: '%s' size: '%dl' count: '%dl' \n", row.getKey(), size, row.getColumns().size())); if (showColumns) { for (Column<C> column : row.getColumns()) { sb.append(String.format(" '%s' (ts='%dl', ttl='%d')\n", column.getName(), column.getTimestamp(), column.getTtl())); } } try { out.write(sb.toString().getBytes()); } catch (IOException e) { } return true; }
private RaigadInstance transform(ColumnList<String> columns) { RaigadInstance ins = new RaigadInstance(); Map<String, String> cmap = new HashMap<String, String>(); for (Column<String> column : columns) { cmap.put(column.getName(), column.getStringValue()); if (column.getName().equals(CN_CLUSTER)) ins.setUpdatetime(column.getTimestamp()); } ins.setId(cmap.get(CN_LOCATION) +"."+ cmap.get(CN_INSTANCEID)); ins.setApp(cmap.get(CN_CLUSTER)); ins.setAvailabilityZone(cmap.get(CN_AZ)); ins.setHostName(cmap.get(CN_HOSTNAME)); ins.setHostIP(cmap.get(CN_IP)); ins.setInstanceId(cmap.get(CN_INSTANCEID)); ins.setAsg(cmap.get(CN_ASGNAME)); ins.setDC(cmap.get(CN_LOCATION)); return ins; }
private AppsInstance transform(ColumnList<String> columns) { AppsInstance ins = new AppsInstance(); Map<String, String> cmap = new HashMap<String, String>(); for (Column<String> column : columns) { // logger.info("***Column Name = "+column.getName()+ " Value = // "+column.getStringValue()); cmap.put(column.getName(), column.getStringValue()); if (column.getName().equals(CN_APPID)) ins.setUpdatetime(column.getTimestamp()); } ins.setApp(cmap.get(CN_APPID)); ins.setZone(cmap.get(CN_AZ)); ins.setHost(cmap.get(CN_HOSTNAME)); ins.setDynomitePort((cmap.get(CN_DYNOMITE_PORT) != null) ? Integer.parseInt(cmap.get(CN_DYNOMITE_PORT)) : commonConfig.getDynomitePort()); ins.setDynomiteSecurePort((cmap.get(CN_DYNOMITE_SECURE_PORT) != null) ? Integer.parseInt(cmap.get(CN_DYNOMITE_SECURE_PORT)) : commonConfig.getDynomiteSecurePort()); ins.setDynomiteSecureStoragePort((cmap.get(CN_DYNOMITE_SECURE_STORAGE_PORT) != null) ? Integer.parseInt(cmap.get(CN_DYNOMITE_SECURE_STORAGE_PORT)) : commonConfig.getDynomiteSecureStoragePort()); ins.setPeerPort((cmap.get(CN_PEER_PORT) != null) ? Integer.parseInt(cmap.get(CN_PEER_PORT)) : commonConfig.getDynomitePeerPort()); ins.setHostIP(cmap.get(CN_EIP)); ins.setId(Integer.parseInt(cmap.get(CN_ID))); ins.setInstanceId(cmap.get(CN_INSTANCEID)); ins.setDatacenter(cmap.get(CN_LOCATION)); ins.setRack(cmap.get(CN_DC)); ins.setToken(cmap.get(CN_TOKEN)); return ins; }
/** * Copies columns exactly, preserving Cassandra timestamp and ttl values. */ private <C> void putAll(ColumnListMutation<C> mutation, Iterable<Column<C>> columns) { for (Column<C> column : columns) { mutation.setTimestamp(column.getTimestamp()) .putColumn(column.getName(), column.getByteBufferValue(), column.getTtl()); } }
/** * Copies columns exactly, preserving Cassandra timestamp and ttl values. */ private <C> void putAll(ColumnListMutation<C> mutation, Iterable<Column<C>> columns) { for (Column<C> column : columns) { mutation.setTimestamp(column.getTimestamp()) .putColumn(column.getName(), column.getByteBufferValue(), column.getTtl()); } }
/** * Copies columns exactly, preserving Cassandra timestamp and ttl values. */ private <C> void putAll(ColumnListMutation<C> mutation, Iterable<Column<C>> columns) { for (Column<C> column : columns) { mutation.setTimestamp(column.getTimestamp()) .putColumn(column.getName(), column.getByteBufferValue(), column.getTtl()); } }
/** * Copies columns exactly, preserving Cassandra timestamp and ttl values. */ private <C> void putAll(ColumnListMutation<C> mutation, Iterable<Column<C>> columns) { for (Column<C> column : columns) { mutation.setTimestamp(column.getTimestamp()) .putColumn(column.getName(), column.getByteBufferValue(), column.getTtl()); } }
context.mb.lockCurrentTimestamp(); for (Column<C> column : row.getColumns()) { mbRow.setTimestamp(column.getTimestamp()); mbRow.putColumn(column.getName(), column.getByteBufferValue(), column.getTtl());
context.mb.lockCurrentTimestamp(); for (Column<C> column : row.getColumns()) { mbRow.setTimestamp(column.getTimestamp()); mbRow.putColumn(column.getName(), column.getByteBufferValue(), column.getTtl());
@ParameterizedTimed(type="AstyanaxStorageProvider") @Override public ByteBuffer readChunk(Table tbl, String blobId, int chunkId, long timestamp) { AstyanaxTable table = (AstyanaxTable) checkNotNull(tbl, "table"); AstyanaxStorage storage = table.getReadStorage(); BlobPlacement placement = (BlobPlacement) storage.getPlacement(); CassandraKeyspace keyspace = placement.getKeyspace(); ColumnQuery<Composite> query = keyspace.prepareQuery(placement.getBlobColumnFamily(), _readConsistency) .getKey(storage.getRowKey(blobId)) .getColumn(getColumn(ColumnGroup.Z, chunkId)); OperationResult<Column<Composite>> operationResult; try { operationResult = query.execute(); } catch (NotFoundException e) { return null; } catch (ConnectionException e) { throw Throwables.propagate(e); } Column<Composite> column = operationResult.getResult(); if (column.getTimestamp() != timestamp) { return null; } ByteBuffer data = column.getByteBufferValue(); _blobReadMeter.mark(data.remaining()); return data; }
private StorageSummary toStorageSummary(ColumnList<Composite> columns) { if (columns.size() == 0) { return null; } // Read the summary column with the attributes, length etc. Column<Composite> summaryColumn = columns.getColumnByIndex(0); if (summaryColumn == null || !matches(summaryColumn.getName(), ColumnGroup.A, 0)) { return null; } StorageSummary summary = JsonHelper.fromJson(summaryColumn.getStringValue(), StorageSummary.class); // Check that all the chunks are available. Some may still be in the process of being written or replicated. if (columns.size() < 1 + summary.getChunkCount()) { return null; } for (int chunkId = 0; chunkId < summary.getChunkCount(); chunkId++) { Column<Composite> presence = columns.getColumnByIndex(chunkId + 1); if (presence == null || !matches(presence.getName(), ColumnGroup.B, chunkId) || presence.getTimestamp() != summary.getTimestamp()) { return null; } } return summary; }
private void deleteOldColumns(AstyanaxTable table, String blobId, ColumnList<Composite> columns, long timestamp) { for (AstyanaxStorage storage : table.getWriteStorage()) { BlobPlacement placement = (BlobPlacement) storage.getPlacement(); // Any columns with a timestamp older than the one we expect must be from an old version // of the blob. This should be rare, but if it happens clean up and delete the old data. MutationBatch mutation = placement.getKeyspace().prepareMutationBatch(ConsistencyLevel.CL_ANY); ColumnListMutation<Composite> row = mutation.withRow( placement.getBlobColumnFamily(), storage.getRowKey(blobId)); boolean found = false; for (Column<Composite> column : columns) { if (column.getTimestamp() < timestamp) { if (ColumnGroup.B.name().equals(column.getName().get(0, AsciiSerializer.get()))) { int chunkId = column.getName().get(1, IntegerSerializer.get()); row.deleteColumn(getColumn(ColumnGroup.B, chunkId)) .deleteColumn(getColumn(ColumnGroup.Z, chunkId)); found = true; } } } if (found) { execute(mutation); } } }