/** {@inheritDoc} */ @Override public void fromBackup(SystemTableBackup backup) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot restore backup to SystemTable instance in state %s.", state); LOG.info(String.format("Restoring system table from backup with %d entries.", backup.getEntries().size())); for (SystemTableEntry entry : backup.getEntries()) { putValue(entry.getKey(), entry.getValue().array()); } // TODO: Flush? //mTable.flushCommits(); }
/** {@inheritDoc} */ @Override public SystemTableBackup toBackup() throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot backup SystemTable instance in state %s.", state); ArrayList<SystemTableEntry> backupEntries = new ArrayList<SystemTableEntry>(); CloseableIterable<SimpleEntry<String, byte[]>> entries = getAll(); for (SimpleEntry<String, byte[]> entry : entries) { backupEntries.add(SystemTableEntry.newBuilder() .setKey(entry.getKey()) .setValue(ByteBuffer.wrap(entry.getValue())) .build()); } return SystemTableBackup.newBuilder().setEntries(backupEntries).build(); }
/** {@inheritDoc} */ @Override public SystemTableBackup toBackup() throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot backup SystemTable instance in state %s.", state); ArrayList<SystemTableEntry> backupEntries = new ArrayList<SystemTableEntry>(); CloseableIterable<SimpleEntry<String, byte[]>> entries = getAll(); for (SimpleEntry<String, byte[]> entry : entries) { backupEntries.add(SystemTableEntry.newBuilder() .setKey(entry.getKey()) .setValue(ByteBuffer.wrap(entry.getValue())) .build()); } return SystemTableBackup.newBuilder().setEntries(backupEntries).build(); }
/** {@inheritDoc} */ @Override public void fromBackup(SystemTableBackup backup) throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.OPEN, "Cannot restore backup to SystemTable instance in state %s.", state); LOG.info(String.format("Restoring system table from backup with %d entries.", backup.getEntries().size())); for (SystemTableEntry entry : backup.getEntries()) { putValue(entry.getKey(), entry.getValue().array()); } mTable.flushCommits(); }
/** * Restores all SystemTable entries from the backup. * * @param backup the deserialized backup of the metadata. * @param fiji the connected Fiji instance. * @throws IOException if there is an error communicating with HBase. */ public void restoreSystemVars(MetadataBackup backup, Fiji fiji) throws IOException { // Restore all System table entries from the file. final FijiSystemTable systemTable = fiji.getSystemTable(); LOG.info("Restoring system table entries..."); systemTable.fromBackup(backup.getSystemTable()); LOG.info(String.format("Restored %d entries.", backup.getSystemTable().getEntries().size())); } }
/** * Restores all SystemTable entries from the backup. * * @param backup the deserialized backup of the metadata. * @param fiji the connected Fiji instance. * @throws java.io.IOException if there is an error communicating with HBase. */ public void restoreSystemVars(MetadataBackup backup, Fiji fiji) throws IOException { // Restore all System table entries from the file. final FijiSystemTable systemTable = fiji.getSystemTable(); LOG.info("Restoring system table entries..."); systemTable.fromBackup(backup.getSystemTable()); LOG.info(String.format("Restored %d entries.", backup.getSystemTable().getEntries().size())); } }