Search in sources :

Example 1 with KeyValue

use of herddb.utils.KeyValue in project herddb by diennea.

the class TableSpaceManager method sendTransactionsDump.

private void sendTransactionsDump(List<Transaction> batch, Channel channel, String dumpId, final int timeout) throws TimeoutException, InterruptedException {
    if (batch.isEmpty()) {
        return;
    }
    List<KeyValue> encodedTransactions = batch.stream().map(tr -> {
        return new KeyValue(Bytes.from_long(tr.transactionId), Bytes.from_array(tr.serialize()));
    }).collect(Collectors.toList());
    long id = channel.generateRequestId();
    try (Pdu response_to_transactionsData = channel.sendMessageWithPduReply(id, PduCodec.TablespaceDumpData.write(id, tableSpaceName, dumpId, "transactions", null, 0, 0, 0, null, encodedTransactions), timeout)) {
        if (response_to_transactionsData.type != Pdu.TYPE_ACK) {
            LOGGER.log(Level.SEVERE, "error response at transactionsData command");
        }
    }
    batch.clear();
}
Also used : HDBException(herddb.client.HDBException) SystablesTableManager(herddb.core.system.SystablesTableManager) CommitTransactionStatement(herddb.model.commands.CommitTransactionStatement) TableCheckpoint(herddb.core.AbstractTableManager.TableCheckpoint) Table(herddb.model.Table) ClientConfiguration(herddb.client.ClientConfiguration) SyslogstatusManager(herddb.core.system.SyslogstatusManager) OpStatsLogger(org.apache.bookkeeper.stats.OpStatsLogger) IndexAlreadyExistsException(herddb.model.IndexAlreadyExistsException) Map(java.util.Map) DDLStatementExecutionResult(herddb.model.DDLStatementExecutionResult) LogNotAvailableException(herddb.log.LogNotAvailableException) PduCodec(herddb.proto.PduCodec) CommitLogResult(herddb.log.CommitLogResult) ClientSideMetadataProviderException(herddb.client.ClientSideMetadataProviderException) LogSequenceNumber(herddb.log.LogSequenceNumber) Set(java.util.Set) ScanStatement(herddb.model.commands.ScanStatement) CountDownLatch(java.util.concurrent.CountDownLatch) Stream(java.util.stream.Stream) HDBClient(herddb.client.HDBClient) TranslatedQuery(herddb.sql.TranslatedQuery) StatsLogger(org.apache.bookkeeper.stats.StatsLogger) TableDataChecksum(herddb.data.consistency.TableDataChecksum) DropTableStatement(herddb.model.commands.DropTableStatement) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Bytes(herddb.utils.Bytes) SysdualTableManager(herddb.core.system.SysdualTableManager) LogEntry(herddb.log.LogEntry) SysnodesTableManager(herddb.core.system.SysnodesTableManager) ArrayList(java.util.ArrayList) CreateIndexStatement(herddb.model.commands.CreateIndexStatement) TableSpaceDoesNotExistException(herddb.model.TableSpaceDoesNotExistException) TransactionContext(herddb.model.TransactionContext) Transaction(herddb.model.Transaction) BRINIndexManager(herddb.index.brin.BRINIndexManager) SystablestatsTableManager(herddb.core.system.SystablestatsTableManager) BiConsumer(java.util.function.BiConsumer) CommitLogListener(herddb.log.CommitLogListener) ForeignKeyDef(herddb.model.ForeignKeyDef) IndexDoesNotExistException(herddb.model.IndexDoesNotExistException) TableSpaceManagerStats(herddb.core.stats.TableSpaceManagerStats) LogEntryType(herddb.log.LogEntryType) LogEntryFactory(herddb.log.LogEntryFactory) IOException(java.io.IOException) DataStorageManager(herddb.storage.DataStorageManager) DropIndexStatement(herddb.model.commands.DropIndexStatement) ColumnTypes(herddb.model.ColumnTypes) ExecutionException(java.util.concurrent.ExecutionException) AtomicLong(java.util.concurrent.atomic.AtomicLong) Column(herddb.model.Column) KeyValue(herddb.utils.KeyValue) FullRecoveryNeededException(herddb.log.FullRecoveryNeededException) StampedLock(java.util.concurrent.locks.StampedLock) ServerHostData(herddb.network.ServerHostData) TableAlreadyExistsException(herddb.model.TableAlreadyExistsException) RollbackTransactionStatement(herddb.model.commands.RollbackTransactionStatement) CreateTableStatement(herddb.model.commands.CreateTableStatement) TimeoutException(java.util.concurrent.TimeoutException) JMXUtils(herddb.jmx.JMXUtils) TransactionResult(herddb.model.TransactionResult) MetadataStorageManager(herddb.metadata.MetadataStorageManager) Channel(herddb.network.Channel) ServerConfiguration(herddb.server.ServerConfiguration) Futures(herddb.utils.Futures) DataStorageManagerException(herddb.storage.DataStorageManagerException) Index(herddb.model.Index) TableDoesNotExistException(herddb.model.TableDoesNotExistException) AlterTableStatement(herddb.model.commands.AlterTableStatement) SysindexcolumnsTableManager(herddb.core.system.SysindexcolumnsTableManager) DataScanner(herddb.model.DataScanner) DDLException(herddb.model.DDLException) StatementExecutionException(herddb.model.StatementExecutionException) Collection(java.util.Collection) SysstatementsTableManager(herddb.core.system.SysstatementsTableManager) BeginTransactionStatement(herddb.model.commands.BeginTransactionStatement) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CompletionException(java.util.concurrent.CompletionException) TableAwareStatement(herddb.model.TableAwareStatement) Logger(java.util.logging.Logger) EOFException(java.io.EOFException) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) HDBConnection(herddb.client.HDBConnection) List(java.util.List) FullTableScanConsumer(herddb.storage.FullTableScanConsumer) SystransactionsTableManager(herddb.core.system.SystransactionsTableManager) NodeMetadata(herddb.model.NodeMetadata) Entry(java.util.Map.Entry) Optional(java.util.Optional) TableSpace(herddb.model.TableSpace) SysconfigTableManager(herddb.core.system.SysconfigTableManager) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) SysindexesTableManager(herddb.core.system.SysindexesTableManager) Statement(herddb.model.Statement) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) DataScannerException(herddb.model.DataScannerException) SystablespacesTableManager(herddb.core.system.SystablespacesTableManager) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Pdu(herddb.proto.Pdu) Level(java.util.logging.Level) HashSet(java.util.HashSet) SysclientsTableManager(herddb.core.system.SysclientsTableManager) TableChecksum(herddb.data.consistency.TableChecksum) ExecutorService(java.util.concurrent.ExecutorService) DumpedLogEntry(herddb.backup.DumpedLogEntry) SysforeignkeysTableManager(herddb.core.system.SysforeignkeysTableManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StatementExecutionResult(herddb.model.StatementExecutionResult) TimeUnit(java.util.concurrent.TimeUnit) CommitLog(herddb.log.CommitLog) ClientSideMetadataProvider(herddb.client.ClientSideMetadataProvider) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) SystablespacereplicastateTableManager(herddb.core.system.SystablespacereplicastateTableManager) SQLPlannedOperationStatement(herddb.model.commands.SQLPlannedOperationStatement) StatementEvaluationContext(herddb.model.StatementEvaluationContext) SyscolumnsTableManager(herddb.core.system.SyscolumnsTableManager) Comparator(java.util.Comparator) Collections(java.util.Collections) TableManagerStats(herddb.core.stats.TableManagerStats) MemoryHashIndexManager(herddb.index.MemoryHashIndexManager) SystemProperties(herddb.utils.SystemProperties) Pdu(herddb.proto.Pdu) KeyValue(herddb.utils.KeyValue)

Example 2 with KeyValue

use of herddb.utils.KeyValue in project herddb by diennea.

the class TableSpaceRestoreSourceFromFile method nextTableDataChunk.

@Override
public List<KeyValue> nextTableDataChunk() throws DataStorageManagerException {
    try {
        int numRecords = in.readVInt();
        if (Integer.MIN_VALUE == numRecords) {
            // EndOfTableMarker
            listener.log("tablefinished", "table finished after " + currentTableSize + " records", Collections.singletonMap("count", numRecords));
            return null;
        }
        listener.log("sendtabledata", "sending " + numRecords + ", total " + currentTableSize, Collections.singletonMap("count", numRecords));
        List<KeyValue> records = new ArrayList<>(numRecords);
        for (int i = 0; i < numRecords; i++) {
            Bytes key = in.readBytes();
            Bytes value = in.readBytes();
            records.add(new KeyValue(key, value));
        }
        currentTableSize += numRecords;
        return records;
    } catch (IOException err) {
        throw new DataStorageManagerException(err);
    }
}
Also used : Bytes(herddb.utils.Bytes) DataStorageManagerException(herddb.storage.DataStorageManagerException) KeyValue(herddb.utils.KeyValue) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 3 with KeyValue

use of herddb.utils.KeyValue in project herddb by diennea.

the class TableSpaceManager method sendDumpedCommitLog.

private void sendDumpedCommitLog(List<DumpedLogEntry> txlogentries, Channel channel, String dumpId, final int timeout) throws TimeoutException, InterruptedException {
    List<KeyValue> batch = new ArrayList<>();
    for (DumpedLogEntry e : txlogentries) {
        batch.add(new KeyValue(Bytes.from_array(e.logSequenceNumber.serialize()), Bytes.from_array(e.entryData)));
    }
    long id = channel.generateRequestId();
    try (Pdu response_to_txlog = channel.sendMessageWithPduReply(id, PduCodec.TablespaceDumpData.write(id, tableSpaceName, dumpId, "txlog", null, 0, 0, 0, null, batch), timeout)) {
        if (response_to_txlog.type != Pdu.TYPE_ACK) {
            LOGGER.log(Level.SEVERE, "error response at txlog command");
        }
    }
}
Also used : Pdu(herddb.proto.Pdu) KeyValue(herddb.utils.KeyValue) DumpedLogEntry(herddb.backup.DumpedLogEntry) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList)

Example 4 with KeyValue

use of herddb.utils.KeyValue in project herddb by diennea.

the class TableSpaceRestoreSourceFromFile method nextTransactionLogChunk.

@Override
public List<KeyValue> nextTransactionLogChunk() throws DataStorageManagerException {
    try {
        int numRecords = in.readVInt();
        listener.log("nexttxchunk", "sending " + numRecords + " tx log entries", Collections.singletonMap("count", numRecords));
        List<KeyValue> records = new ArrayList<>(numRecords);
        for (int i = 0; i < numRecords; i++) {
            long ledgerId = in.readVLong();
            long offset = in.readVLong();
            Bytes value = in.readBytes();
            records.add(new KeyValue(Bytes.from_array(new LogSequenceNumber(ledgerId, offset).serialize()), value));
        }
        return records;
    } catch (IOException err) {
        throw new DataStorageManagerException(err);
    }
}
Also used : Bytes(herddb.utils.Bytes) DataStorageManagerException(herddb.storage.DataStorageManagerException) KeyValue(herddb.utils.KeyValue) ArrayList(java.util.ArrayList) LogSequenceNumber(herddb.log.LogSequenceNumber) IOException(java.io.IOException)

Aggregations

KeyValue (herddb.utils.KeyValue)4 ArrayList (java.util.ArrayList)4 DataStorageManagerException (herddb.storage.DataStorageManagerException)3 Bytes (herddb.utils.Bytes)3 IOException (java.io.IOException)3 DumpedLogEntry (herddb.backup.DumpedLogEntry)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ClientConfiguration (herddb.client.ClientConfiguration)1 ClientSideMetadataProvider (herddb.client.ClientSideMetadataProvider)1 ClientSideMetadataProviderException (herddb.client.ClientSideMetadataProviderException)1 HDBClient (herddb.client.HDBClient)1 HDBConnection (herddb.client.HDBConnection)1 HDBException (herddb.client.HDBException)1 TableCheckpoint (herddb.core.AbstractTableManager.TableCheckpoint)1 TableManagerStats (herddb.core.stats.TableManagerStats)1 TableSpaceManagerStats (herddb.core.stats.TableSpaceManagerStats)1 SysclientsTableManager (herddb.core.system.SysclientsTableManager)1 SyscolumnsTableManager (herddb.core.system.SyscolumnsTableManager)1 SysconfigTableManager (herddb.core.system.SysconfigTableManager)1