private long getId(Uid uid, String typeName) { RecordInfo record = getContentForType(typeName).get(uid); if(record != null) { return record.id; } else { return maxID.incrementAndGet(); } } }
/** * @return the "name" of the object store. Where in the hierarchy it appears, e.g., /ObjectStore/MyName/... */ @Override public String getStoreName() { return store.getStoreName(); }
/** * Read the object's committed state. * * @param u The object to work on. * @param typeName The type of the object to work on. * @return the state of the object. */ @Override public InputObjectState read_committed(Uid u, String typeName) throws ObjectStoreException { if(tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("HornetqObjectStore.read_committed("+u+", "+typeName+")"); } typeName = ensureTypenamePrefix(typeName); return store.read_committed(u, typeName); }
/** * 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); UidHelper.unpackFrom(inputBuffer); inputBuffer.unpackString(); return new InputObjectState(uid, typeName, inputBuffer.unpackBytes()); } catch(Exception e) { throw new ObjectStoreException(e); } }
/** * Remove the object's committed state. * * @param uid The object to work on. * @param typeName The type of the object to work on. * @return <code>true</code> if no errors occurred, <code>false</code> * otherwise. * @throws ObjectStoreException if things go wrong. */ public boolean remove_committed(Uid uid, String typeName) throws ObjectStoreException { try { RecordInfo record = getContentForType(typeName).remove(uid); long id = (record != null ? record.id : getId(uid, typeName)); journal.appendDeleteRecord(id, syncDeletes); return true; } catch (IllegalStateException e) { tsLogger.i18NLogger.warn_hornetqobjectstore_remove_state_exception(e); return false; } catch(Exception e) { throw new ObjectStoreException(e); } }
public Uid[] getUidsForType(String typeName) { Set<Uid> keySet = getContentForType(typeName).keySet(); return keySet.toArray(new Uid[keySet.size()]); }
String[] knownTypes = store.getKnownTypes(); // may contain trailing null elements Set<String> typeSet = new HashSet<String>(); return true; OutputObjectState buffer = new OutputObjectState(); if(!typeSet.contains(value)) { typeSet.add(value); buffer.packString(value); buffer.packString(typeName); throw new ObjectStoreException(e); foundTypes.setBuffer(buffer.buffer());
typeName = ensureTypenamePrefix(typeName); Uid[] uids = store.getUidsForType(typeName); // may contain trailing null elements OutputObjectState buffer = new OutputObjectState(); UidHelper.packInto(uid, buffer); UidHelper.packInto(Uid.nullUid(), buffer); throw new ObjectStoreException(e); foundInstances.setBuffer(buffer.buffer());
UidHelper.packInto(uid, outputBuffer); outputBuffer.packString(typeName); outputBuffer.packBytes(txData.buffer()); long id = getId(uid, typeName); byte[] data = outputBuffer.buffer(); if(getContentForType(typeName).containsKey(uid)) { journal.appendUpdateRecord(id, RECORD_TYPE, data, syncWrites); } else { getContentForType(typeName).put(uid, record); } catch(Exception e) { throw new ObjectStoreException(e);
/** * @param u The object to query. * @param typeName The type of the object to query. * @return the current state of the object's state (e.g., shadowed, * committed ...) [StateStatus] */ @Override public int currentState(Uid u, String typeName) throws ObjectStoreException { if(tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("HornetqObjectStore.currentState("+u+", "+typeName+")"); } typeName = ensureTypenamePrefix(typeName); if( store.contains(u, typeName)) { return StateStatus.OS_COMMITTED; } else { return StateStatus.OS_UNKNOWN; } }
/** * Remove the object's committed state. * * @param u The object to work on. * @param typeName The type of the object to work on. * @return <code>true</code> if no errors occurred, <code>false</code> * otherwise. */ @Override public boolean remove_committed(Uid u, String typeName) throws ObjectStoreException { if(tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("HornetqObjectStore.remove_committed("+u+", "+typeName+")"); } typeName = ensureTypenamePrefix(typeName); return store.remove_committed(u, typeName); }
/** * Remove the object's committed state. * * @param uid The object to work on. * @param typeName The type of the object to work on. * @return <code>true</code> if no errors occurred, <code>false</code> * otherwise. * @throws ObjectStoreException if things go wrong. */ public boolean remove_committed(Uid uid, String typeName) throws ObjectStoreException { try { long id = getId(uid, typeName); // look up the id *before* doing the remove from state, or it won't be there any more. getContentForType(typeName).remove(uid); journal.appendDeleteRecord(id, syncDeletes); } catch(Exception e) { throw new ObjectStoreException(e); } return true; }
public HornetqObjectStoreAdaptor() throws IOException { HornetqJournalEnvironmentBean envBean = BeanPopulator.getDefaultInstance(HornetqJournalEnvironmentBean.class); this.store = new HornetqJournalStore(envBean); }
@Override public void start() { if(tsLogger.logger.isTraceEnabled()) { tsLogger.logger.trace("HornetqObjectStore.start()"); } try { store.start(); } catch(Exception e) { throw new RuntimeException(e); } }
private long getId(Uid uid, String typeName) { synchronized (uidMappingLock) { RecordInfo record = getContentForType(typeName).get(uid); if(record != null) { return record.id; } else { maxID++; return maxID; } } } }
/** * 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); UidHelper.unpackFrom(inputBuffer); inputBuffer.unpackString(); return new InputObjectState(uid, typeName, inputBuffer.unpackBytes()); } catch(Exception e) { throw new ObjectStoreException(e); } }
/** * Remove the object's committed state. * * @param uid The object to work on. * @param typeName The type of the object to work on. * @return <code>true</code> if no errors occurred, <code>false</code> * otherwise. * @throws ObjectStoreException if things go wrong. */ public boolean remove_committed(Uid uid, String typeName) throws ObjectStoreException { try { RecordInfo record = getContentForType(typeName).remove(uid); long id = (record != null ? record.id : getId(uid, typeName)); journal.appendDeleteRecord(id, syncDeletes); return true; } catch (IllegalStateException e) { tsLogger.i18NLogger.warn_hornetqobjectstore_remove_state_exception(e); return false; } catch(Exception e) { throw new ObjectStoreException(e); } }
public Uid[] getUidsForType(String typeName) { Set<Uid> keySet = getContentForType(typeName).keySet(); return keySet.toArray(new Uid[keySet.size()]); }
String[] knownTypes = store.getKnownTypes(); // may contain trailing null elements Set<String> typeSet = new HashSet<String>(); return true; OutputObjectState buffer = new OutputObjectState(); if(!typeSet.contains(value)) { typeSet.add(value); buffer.packString(value); buffer.packString(typeName); throw new ObjectStoreException(e); foundTypes.setBuffer(buffer.buffer());
typeName = ensureTypenamePrefix(typeName); Uid[] uids = store.getUidsForType(typeName); // may contain trailing null elements OutputObjectState buffer = new OutputObjectState(); UidHelper.packInto(uid, buffer); UidHelper.packInto(Uid.nullUid(), buffer); throw new ObjectStoreException(e); foundInstances.setBuffer(buffer.buffer());