/** * Create a new buffer and copy the provided one. */ public InputBuffer(InputBuffer buff) { _byteArray = null; _valid = false; _inputStream = null; _input = null; copy(buff); }
/** * Unpack the next byte array from the stream. If the next item in the * buffer is not of the right type then an IOException is thrown. */ public final synchronized byte[] unpackBytes () throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_InputBuffer_2()); int size = unpackInt(); byte b[] = new byte[size]; if (size > 0) { _input.read(b, 0, size); realign(size); } return b; }
/** * Reset the read pointer for this buffer. */ public final boolean reread () { if (!_valid) return false; try { _inputStream = new ByteArrayInputStream(_byteArray); _input = new DataInputStream(_inputStream); skipHeader(); } catch (IOException e) { _valid = false; } return _valid; }
public synchronized void unpackFrom (InputBuffer buff) throws IOException { imageType = buff.unpackString(); bufferUid = UidHelper.unpackFrom(buff); super.unpackFrom(buff); }
/** * Unpack the next byte array from the stream. If the next item in the * buffer is not of the right type then an IOException is thrown. */ public final synchronized byte[] unpackBytes () throws IOException { if (!_valid) throw new IOException(tsLogger.log_mesg .getString("com.arjuna.ats.arjuna.state.InputBuffer_2")); int size = unpackInt(); byte b[] = new byte[size]; if (size > 0) { _input.read(b, 0, size); realign(size); } return b; }
/** * Unpack a buffer from the provided buffer, and initialise this instance * with it. If the next item in the buffer is not of the right type then an * IOException is thrown. */ public synchronized void unpackFrom (InputBuffer buff) throws IOException { if (buff == null) throw new IOException(tsLogger.i18NLogger.get_state_InputBuffer_11()); _valid = false; /* * unpack number of bytes, then create new byte array and unpack each * byte separately. */ _byteArray = buff.unpackBytes(); _valid = true; try { _inputStream = new ByteArrayInputStream(_byteArray); _input = new DataInputStream(_inputStream); skipHeader(); } catch (IOException e) { _valid = false; } }
public void start() throws Exception { journal.start(); List<RecordInfo> committedRecords = new LinkedList<RecordInfo>(); List<PreparedTransactionInfo> preparedTransactions = new LinkedList<PreparedTransactionInfo>(); TransactionFailureCallback failureCallback = new TransactionFailureCallback() { public void failedTransaction(long l, java.util.List<org.hornetq.core.journal.RecordInfo> recordInfos, java.util.List<org.hornetq.core.journal.RecordInfo> recordInfos1) { tsLogger.i18NLogger.warn_journal_load_error(); } }; JournalLoadInformation journalLoadInformation = journal.load(committedRecords, preparedTransactions, failureCallback); maxID = journalLoadInformation.getMaxID(); if(!preparedTransactions.isEmpty()) { tsLogger.i18NLogger.warn_journal_load_error(); } for(RecordInfo record : committedRecords) { InputBuffer inputBuffer = new InputBuffer(record.data); Uid uid = UidHelper.unpackFrom(inputBuffer); String typeName = inputBuffer.unpackString(); getContentForType(typeName).put(uid, record); // don't unpack the rest yet, we may never need it. read_committed does it on demand. } }
/** * Read the object's committed state. * * @param uid The object to work on. * @param typeName The type of the object to work on. * @return the state of the object. * @throws ObjectStoreException if things go wrong. */ public InputObjectState read_committed(Uid uid, String typeName) throws ObjectStoreException { RecordInfo record = getContentForType(typeName).get(uid); if(record == null) { return null; } // this repeated unpacking is a little inefficient - subclass RecordInfo to hold unpacked form too? // not too much of an issue as log reads are done for recovery only. try { InputBuffer inputBuffer = new InputBuffer(record.data); Uid unpackedUid = UidHelper.unpackFrom(inputBuffer); String unpackedTypeName = inputBuffer.unpackString(); InputObjectState inputObjectState = new InputObjectState(uid, typeName, inputBuffer.unpackBytes()); return inputObjectState; } catch(Exception e) { throw new ObjectStoreException(e); } }
ActionInfo temp = new ActionInfo(); newDepth = state.unpackInt(); IOException ioException = new IOException(tsLogger.i18NLogger.get_coordinator_ActionHierarchy_1()); ioException.initCause(ex); throw ioException; temp.actionUid = UidHelper.unpackFrom(state); temp.actionType = state.unpackInt();
/** * Unpack a short from the stream. If the next item in the buffer is not of * the right type then an IOException is thrown. */ public final synchronized short unpackShort () throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_InputBuffer_5()); int i = unpackInt(); return (short) i; }
public void copyFrom (OutputObjectState copyFrom) { super.setBuffer(copyFrom.buffer()); bufferUid = new Uid(copyFrom.stateUid()); super._valid = bufferUid.valid(); imageType = new String(copyFrom.type()); }
public void print (PrintWriter strm) { strm.println("InputObjectState Uid : "+bufferUid+"\n"); if (imageType != null) strm.println("InputObjectState Type : "+imageType+"\n"); else strm.println("InputObjectState Type : null\n"); strm.println("InputObjectState Size : "+size()+"\n"); strm.println("InputObjectState Buffer: "); super.print(strm); }
/** * Unpack a byte from the stream. If the next item in the buffer is not of * the right type then an IOException is thrown. */ public final synchronized byte unpackByte () throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_InputBuffer_1()); int i = unpackInt(); return (byte) i; }
/** * Unpack a character from the stream. If the next item in the buffer is not * of the right type then an IOException is thrown. */ public final synchronized char unpackChar () throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_InputBuffer_4()); int i = unpackInt(); return (char) i; }
public static final Uid unpackFrom (InputBuffer buff) throws IOException { if (buff == null) throw new IllegalArgumentException(); return new Uid(buff.unpackBytes()); }
public void start() throws Exception { journal.start(); List<RecordInfo> committedRecords = new LinkedList<RecordInfo>(); List<PreparedTransactionInfo> preparedTransactions = new LinkedList<PreparedTransactionInfo>(); TransactionFailureCallback failureCallback = new TransactionFailureCallback() { public void failedTransaction(long l, java.util.List<org.hornetq.core.journal.RecordInfo> recordInfos, java.util.List<org.hornetq.core.journal.RecordInfo> recordInfos1) { tsLogger.i18NLogger.warn_journal_load_error(); } }; JournalLoadInformation journalLoadInformation = journal.load(committedRecords, preparedTransactions, failureCallback); maxID = journalLoadInformation.getMaxID(); if(!preparedTransactions.isEmpty()) { tsLogger.i18NLogger.warn_journal_load_error(); } for(RecordInfo record : committedRecords) { InputBuffer inputBuffer = new InputBuffer(record.data); Uid uid = UidHelper.unpackFrom(inputBuffer); String typeName = inputBuffer.unpackString(); getContentForType(typeName).put(uid, record); // don't unpack the rest yet, we may never need it. read_committed does it on demand. } }
public synchronized void unpackFrom (InputBuffer buff) throws IOException { imageType = buff.unpackString(); bufferUid = UidHelper.unpackFrom(buff); super.unpackFrom(buff); }
/** * Unpack a short from the stream. If the next item in the buffer is not of * the right type then an IOException is thrown. */ public final synchronized short unpackShort () throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_InputBuffer_5()); int i = unpackInt(); return (short) i; }
public void copyFrom (OutputObjectState copyFrom) { super.setBuffer(copyFrom.buffer()); bufferUid = new Uid(copyFrom.stateUid()); super._valid = bufferUid.valid(); imageType = (copyFrom.type() == null ? null : new String(copyFrom.type())); }
public void print (PrintWriter strm) { strm.println("InputObjectState Uid : "+bufferUid+"\n"); if (imageType != null) strm.println("InputObjectState Type : "+imageType+"\n"); else strm.println("InputObjectState Type : null\n"); strm.println("InputObjectState Size : "+size()+"\n"); strm.println("InputObjectState Buffer: "); super.print(strm); }