Java Code Examples for com.datastax.driver.core.BatchStatement.Type#UNLOGGED
The following examples show how to use
com.datastax.driver.core.BatchStatement.Type#UNLOGGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraVideoV2Dao.java From arcusplatform with Apache License 2.0 | 6 votes |
@Override public ListenableFuture<?> delete(UUID placeId, UUID recordingId, boolean isFavorite, Date purgeTime, int purgePartitionId) { BatchStatement stmt = new BatchStatement(Type.UNLOGGED); addDeleteStatements(stmt, placeId, recordingId, isFavorite, purgeTime, purgePartitionId); // Add to Purge table if it's favorite if(isFavorite) { VideoMetadata metadata = findByPlaceAndId(placeId, recordingId); metadata.setDeletionTime(purgeTime); metadata.setDeletionPartition(purgePartitionId); addStatementsForRemoveFromFavoriteTables(stmt, metadata); } long startTime = System.nanoTime(); ResultSetFuture result = session.executeAsync(stmt); result.addListener(() -> DeleteTimer.update(System.nanoTime() - startTime, TimeUnit.NANOSECONDS), MoreExecutors.directExecutor()); return result; }
Example 2
Source File: CassandraRepo.java From monasca-persister with Apache License 2.0 | 6 votes |
public int handleFlush_batch(String id) { Statement query; int flushedCount = 0; BatchStatement batch = new BatchStatement(Type.UNLOGGED); while ((query = queue.poll()) != null) { flushedCount++; batch.add(query); } executeQuery(id, batch, System.nanoTime()); metricCompleted.inc(flushedCount); return flushedCount; }
Example 3
Source File: CassandraVideoV2Dao.java From arcusplatform with Apache License 2.0 | 5 votes |
private void complete(UUID placeId, UUID recordingId, long expiration, long actualTtlInSeconds, double duration, long size) { BatchStatement stmt = new BatchStatement(Type.UNLOGGED); // recording will be atomic, and place_recording will be atomic, but they will be independently atomic to save performance stmt.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); addDurationAndSizeStatements(stmt, placeId, recordingId, duration, size, expiration, actualTtlInSeconds); // Recording Metadata Index Mutations stmt.add(placeRecordingIndex.insertRecording(placeId, recordingId, size, expiration, actualTtlInSeconds)); executeAndUpdateTimer(session, stmt, CompleteTimer); }
Example 4
Source File: CassandraVideoV2Dao.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override public void completeAndDelete(UUID placeId, UUID recordingId, double duration, long size, Date purgeTime, int purgePartitionId, long ttlInSeconds) { BatchStatement stmt = new BatchStatement(Type.UNLOGGED); // recording will be atomic, and place_recording will be atomic, but they will be independently atomic to save performance stmt.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); addDurationAndSizeStatements(stmt, placeId, recordingId, duration, size, ttlInSeconds); addDeleteStatements(stmt, placeId, recordingId, false, purgeTime, purgePartitionId); executeAndUpdateTimer(session, stmt, CompleteTimer); }
Example 5
Source File: CassandraVideoV2Dao.java From arcusplatform with Apache License 2.0 | 4 votes |
@Override public void insert(VideoMetadata metadata) { BatchStatement stmt = new BatchStatement(Type.UNLOGGED); // recording will be atomic, and place_recording will be atomic, but they will be independently atomic to save performance UUID placeId = metadata.getPlaceId(); UUID recordingId = metadata.getRecordingId(); UUID personId = metadata.getPersonId(); // Recording Metadata Table Mutations long expiration = metadata.getExpiration(); Date purgeAt = new Date(expiration); //Make sure expiration value matches with delete time since we add a delay + round to the next hour when calculating the delete time //Therefore, the expiration time will be a little longer than what is defined for the service level. long actualTtlInSec = VideoV2Util.createActualTTL(recordingId, expiration); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.NAME, metadata.getName())); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.PLACEID, String.valueOf(metadata.getPlaceId()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.ACCOUNTID, String.valueOf(metadata.getAccountId()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.CAMERAID, String.valueOf(metadata.getCameraId()))); if (personId != null) { stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.PERSONID, String.valueOf(personId))); } stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.WIDTH, String.valueOf(metadata.getWidth()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.HEIGHT, String.valueOf(metadata.getHeight()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.BANDWIDTH, String.valueOf(metadata.getBandwidth()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.FRAMERATE, String.valueOf(metadata.getFramerate()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.PRECAPTURE, String.valueOf(metadata.getPrecapture()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.LOCATION, String.valueOf(metadata.getLoc()))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.TYPE, metadata.isStream() ? VideoMetadataV2Table.ATTR_TYPE_STREAM : VideoMetadataV2Table.ATTR_TYPE_RECORDING)); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.EXPIRATION, String.valueOf(expiration))); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.DELETED_TIME, String.valueOf(purgeAt.getTime()))); int partitionId = VideoDao.calculatePartitionId(recordingId, config.getPurgePartitions()); metadata.setDeletionPartition(partitionId); stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.DELETED_PARTITION, String.valueOf(partitionId))); if(metadata.getVideoCodec() != null) { stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.VIDEO_CODEC, metadata.getVideoCodec().name())); } if(metadata.getAudioCodec() != null) { stmt.add(recordingMetadataTable.insertField(recordingId, expiration, actualTtlInSec, MetadataAttribute.AUDIO_CODEC, metadata.getAudioCodec().name())); } // Recording Table Mutations stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.STORAGE, toblob(metadata.getLoc()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.ACCOUNT, toblob(metadata.getAccountId()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.PLACE, toblob(metadata.getPlaceId()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.CAMERA, toblob(metadata.getCameraId()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.EXPIRATION, toblob(expiration))); if (metadata.getPersonId() != null) { stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.PERSON, toblob(metadata.getPersonId()))); } stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.WIDTH, toblob(metadata.getWidth()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.HEIGHT, toblob(metadata.getHeight()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.BANDWIDTH,toblob(metadata.getBandwidth()))); stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.FRAMERATE,toblob(metadata.getFramerate()))); if(metadata.getVideoCodec() != null) { stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.VIDEO_CODEC, toblob(metadata.getVideoCodec()))); } if(metadata.getAudioCodec() != null) { stmt.add(recordingTable.insertField(recordingId, expiration, actualTtlInSec, RecordingTableField.AUDIO_CODEC, toblob(metadata.getAudioCodec()))); } // Recording Metadata Index Mutations stmt.add(placeRecordingIndex.insertCamera(placeId, recordingId, metadata.getCameraId(), expiration, actualTtlInSec)); stmt.add(placeRecordingIndex.insertVideo(placeId, recordingId, metadata.isStream() ? PlaceRecordingIndexV2Table.Type.STREAM : PlaceRecordingIndexV2Table.Type.RECORDING, expiration, actualTtlInSec)); // Purge table addPurgeStatements(stmt, placeId, recordingId, purgeAt, partitionId, metadata.getLoc(), !metadata.isStream()); VideoV2Util.executeAndUpdateTimer(session, stmt, InsertVideoTimer); }
Example 6
Source File: CQLTransaction.java From Doradus with Apache License 2.0 | 4 votes |
private void executeUpdatesSynchronous(DBTransaction transaction) { BatchStatement batchState = new BatchStatement(Type.UNLOGGED); batchState.addAll(getMutations(transaction)); executeBatch(batchState); }