protected void addGroup (long id, String groupName) { if (groupName != null) psp.out (getKey (GROUPS, id), groupName); } protected void purge (long id, boolean full) {
protected boolean tailDone () { String stateKey = getKey(STATE, tail); if (DONE.equals (psp.rdp (stateKey))) { purge (tail, true); return true; } return false; } protected long nextId () {
protected void purge (long id, boolean full) { String stateKey = getKey (STATE, id); String contextKey = getKey (CONTEXT, id); String groupsKey = getKey (GROUPS, id); synchronized (psp) { commitOff (psp); if (full) SpaceUtil.wipe(psp, stateKey); SpaceUtil.wipe(psp, contextKey); SpaceUtil.wipe(psp, groupsKey); commitOn (psp); } }
protected List<TransactionParticipant> getParticipants (long id) { // Use a local copy of participant to avoid adding the // GROUP participant to the DEFAULT_GROUP List<TransactionParticipant> participantsChain = new ArrayList(); List<TransactionParticipant> participants = getParticipants (DEFAULT_GROUP); // Add DEFAULT_GROUP participants participantsChain.addAll(participants); String key = getKey(GROUPS, id); String grp; // now add participants of Group while ( (grp = (String) psp.inp (key)) != null) { participantsChain.addAll (getParticipants (grp)); } return participantsChain; }
protected void snapshot (long id, Serializable context, Integer status) { String contextKey = getKey (CONTEXT, id); synchronized (psp) { commitOff (psp); SpaceUtil.wipe(psp, contextKey); if (context != null) psp.out (contextKey, context); if (status != null) { String stateKey = getKey (STATE, id); psp.put (stateKey, status); } commitOn (psp); } } protected void setState (long id, Integer state) {
protected void setState (long id, Integer state) { String stateKey = getKey (STATE, id); synchronized (psp) { commitOff (psp); SpaceUtil.wipe(psp, stateKey); if (state!= null) psp.out (stateKey, state); commitOn (psp); } } protected void addGroup (long id, String groupName) {
@Test public void testGetKeyThrowsNullPointerException() throws Throwable { try { transactionManager.getKey(null, 100L); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
protected void recover (int session, long id) { LogEvent evt = getLog().createLogEvent ("recover"); Profiler prof = new Profiler(); evt.addMessage ("<id>" + id + "</id>"); try { String stateKey = getKey (STATE, id); String contextKey = getKey (CONTEXT, id); Integer state = (Integer) psp.rdp (stateKey); if (state == null) { evt.addMessage ("unknown stateKey " + stateKey); SpaceUtil.wipe (psp, contextKey); // just in case ... return; } Serializable context = (Serializable) psp.rdp (contextKey); if (context != null) evt.addMessage (context); if (DONE.equals (state)) { evt.addMessage ("<done/>"); } else if (COMMITTING.equals (state)) { commit (session, id, context, getParticipants (id), true, evt, prof); } else if (PREPARING.equals (state)) { abort (session, id, context, getParticipants (id), true, evt, prof); } purge (id, true); } finally { evt.addMessage (prof); Logger.log (evt); } } protected synchronized void checkRetryTask () {