private void flushInput() { SpaceUtil.wipe(sp,in); }
/** * @param key * key whose mapping is to be removed from registrar. */ public static void unregister(String key) { SpaceUtil.wipe(sp, key); }
private void takeOffline() { SpaceUtil.wipe(sp, ready); }
private ISOChannel getNextChannel() { ISOChannel c = null; for (int size = channels.length; size > 0; size--) { c = channels[roundRobinCounter++ % channels.length]; if (c != null && c.isConnected()) break; } if (c == null) SpaceUtil.wipe(sp, ready); return c; } private int getConnectedCount() {
private void waitForReceiverToExit() { join(receiver); SpaceUtil.wipe(sp, ready); } private void join(Thread thread) {
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); } }
public static long nextLong (Space sp, Object key) { long l = 0L; synchronized (sp) { Object obj = sp.inp (key); wipe (sp, key); // just in case if (obj instanceof Long) l = (Long) obj; sp.out (key, ++l); } return l; } public static boolean outIfEmpty (Space sp, Object key, Object value, long nrdTimeout, long outTimeout) {
protected void disconnect () { // do not synchronize on this as both Sender and Receiver can deadlock against a thread calling stop() synchronized (disconnectLock) { try { SpaceUtil.wipe(sp, ready); channel.disconnect(); } catch (Exception e) { getLog().warn("disconnect", e); } } } public synchronized void setHost (String host) {
private void disconnect (ISOChannel channel) { try { if (getConnectedCount() <= 1) SpaceUtil.wipe(sp, ready); channel.disconnect (); } catch (IOException e) { getLog().warn ("disconnect", e); } } private void disconnectAll() {
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 testWipeThrowsNullPointerException() throws Throwable { try { SpaceUtil.wipe(null, ""); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } } }
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) {
@Test public void testWipe1() throws Throwable { SpaceUtil.wipe(SpaceFactory.getSpace(), ""); assertTrue("Test completed without Exception", true); // dependencies on static and environment state led to removal of 1 // assertion }
protected void checkConnection () { while (running() && sp.rdp (reconnect) != null) { ISOUtil.sleep(1000); } while (running() && !channel.isConnected ()) { SpaceUtil.wipe(sp, ready); try { channel.connect (); } catch (IOException ignored) { // channel.connect already logs - no need for more warnings } if (!channel.isConnected ()) ISOUtil.sleep (delay); else connects++; } if (running() && sp.rdp (ready) == null) sp.out (ready, new Date()); } protected void disconnect () {
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 () {
SpaceUtil.wipe(psp, entry.responseKey); if (entry.responseTimeout > 0L) psp.out(entry.responseKey, resp, entry.responseTimeout);