/** * Remove endpoint from remembered set. If set becomes empty, * remove server from Transport's object table. */ synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong) { // check sequence number for vmid SequenceEntry entry = sequenceTable.get(vmid); if (entry == null || entry.sequenceNum > sequenceNum) { // late clean call; ignore return; } else if (strong) { // strong clean call; retain sequenceNum entry.retain(sequenceNum); } else if (entry.keep == false) { // get rid of sequence number sequenceTable.remove(vmid); } if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) { DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid); } refSetRemove(vmid); }
/** * Mark this target as not accepting new calls if any of the * following conditions exist: a) the force parameter is true, * b) the target's call count is zero, or c) the object is already * not accepting calls. Returns true if target is marked as not * accepting new calls; returns false otherwise. */ synchronized boolean unexport(boolean force) { if ((force == true) || (callCount == 0) || (disp == null)) { disp = null; /* * Fix for 4331349: unpin object so that it may be gc'd. * Also, unregister all vmids referencing this target * so target can be gc'd. */ unpinImpl(); DGCImpl dgc = DGCImpl.getDGCImpl(); Enumeration<VMID> enum_ = refSet.elements(); while (enum_.hasMoreElements()) { VMID vmid = enum_.nextElement(); dgc.unregisterTarget(vmid, this); } return true; } else { return false; } }
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { int version = in.readInt (); int size = in.readInt(); entries = new ArrayList (size); map = new gnu.trove.TObjectIntHashMap (size); for (int i = 0; i < size; i++) { Object o = in.readObject(); map.put (o, i); entries. add (o); } growthStopped = in.readBoolean(); entryClass = (Class) in.readObject(); if (version >0 ){ // instanced id added in version 1S instanceId = (VMID) in.readObject(); } }
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { //throw new UnsupportedOperationException(); int version = in.readInt (); this.alphaId = (String)in.readObject(); this.entriesId = (String)in.readObject(); //this.alphabetEntries = this.getEntries(); //this.alphabetMap = this.getMap(); /* for (int i = 0; i < size; i++) { Object o = in.readObject(); map.put (o, i); entries. add (o); } */ growthStopped = in.readBoolean(); entryClass = (Class) in.readObject(); if (version >0 ){ // instanced id added in version 1S instanceId = (VMID) in.readObject(); } }
public static String newId() { String result = new VMID().toString(); result = result.replace('0', 'G'); result = result.replace('1', 'H'); result = result.replace('2', 'I'); result = result.replace('3', 'J'); result = result.replace('4', 'K'); result = result.replace('5', 'L'); result = result.replace('6', 'M'); result = result.replace('7', 'N'); result = result.replace('8', 'O'); result = result.replace('9', 'P'); result = result.replaceAll("-", ""); result = result.replaceAll(":", ""); return result; }
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { lock = new ReentrantReadWriteLock(); lock.writeLock().lock(); try { int version = in.readInt(); int size = in.readInt(); entries = new ArrayList(size); map = new TObjectIntHashMap(size); for (int i = 0; i < size; i++) { Object o = in.readObject(); map.put(o, i); entries.add(o); } growthStopped = in.readBoolean(); entryClass = (Class) in.readObject(); if (version > 0) { // instanced id added in version 1S instanceId = (VMID) in.readObject(); } } finally { lock.writeLock().unlock(); } }
/** * Remove endpoint from remembered set. If set becomes empty, * remove server from Transport's object table. */ synchronized void unreferenced(long sequenceNum, VMID vmid, boolean strong) { // check sequence number for vmid SequenceEntry entry = (SequenceEntry) sequenceTable.get(vmid); if (entry == null || entry.sequenceNum > sequenceNum) { // late clean call; ignore return; } else if (strong) { // strong clean call; retain sequenceNum entry.retain(sequenceNum); } else if (entry.keep == false) { // get rid of sequence number sequenceTable.remove(vmid); } if (DGCImpl.dgcLog.isLoggable(Log.VERBOSE)) { DGCImpl.dgcLog.log(Log.VERBOSE, "remove from dirty set: " + vmid); } refSetRemove(vmid); }
/** * Mark this target as not accepting new calls if any of the * following conditions exist: a) the force parameter is true, * b) the target's call count is zero, or c) the object is already * not accepting calls. Returns true if target is marked as not * accepting new calls; returns false otherwise. */ synchronized boolean unexport(boolean force) { if ((force == true) || (callCount == 0) || (disp == null)) { disp = null; /* * Fix for 4331349: unpin object so that it may be gc'd. * Also, unregister all vmids referencing this target * so target can be gc'd. */ unpinImpl(); DGCImpl dgc = DGCImpl.getDGCImpl(); Enumeration enum_ = refSet.elements(); while (enum_.hasMoreElements()) { VMID vmid = (VMID) enum_.nextElement(); dgc.unregisterTarget(vmid, this); } return true; } else { return false; } }
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { int version = in.readInt (); int size = in.readInt(); entries = new ArrayList (size); map = new ObjectIntOpenHashMap (size); for (int i = 0; i < size; i++) { Object o = in.readObject(); map.put (o, i); entries. add (o); } growthStopped = in.readBoolean(); entryClass = (Class) in.readObject(); if (version >0 ){ // instanced id added in version 1S instanceId = (VMID) in.readObject(); } }
void dgcDirty(VMID vmid, long seqNum, long duration) { synchronized (vmidTable) { DGCExpirationInfo info = (DGCExpirationInfo) vmidTable.get(vmid); if (info != null && info.seqNum >= seqNum) { return; } Long l = (Long) rememberedTable.get(vmid); if (l != null) { if (l.longValue() > seqNum) { return; } else { rememberedTable.remove(vmid); } } ref.makeStrong(true); vmidTable.put(vmid, new DGCExpirationInfo(duration, seqNum)); } }
boolean dgcClean(VMID vmid, long seqNum, boolean strong) { synchronized (vmidTable) { DGCExpirationInfo info = (DGCExpirationInfo) vmidTable.get(vmid); if (info != null && info.seqNum >= seqNum) { return false; } vmidTable.remove(vmid); if (strong) { Long l = (Long) rememberedTable.get(vmid); if (l != null && l.longValue() > seqNum) { return true; } rememberedTable.put(vmid, new Long(seqNum)); } if (vmidTable.isEmpty()) { unreferenced(); } return true; } }
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { lock = new ReentrantReadWriteLock(); lock.writeLock().lock(); try { int version = in.readInt(); int size = in.readInt(); entries = new ArrayList(size); map = new ObjectIntHashMap(size); for (int i = 0; i < size; i++) { Object o = in.readObject(); map.put(o, i); entries.add(o); } growthStopped = in.readBoolean(); entryClass = (Class) in.readObject(); if (version > 0) { // instanced id added in version 1S instanceId = (VMID) in.readObject(); } } finally { lock.writeLock().unlock(); } }
/** * Starts all the periodic actions and Starts the local Garbage Collector */ public DGCImpl() { super("rmi.dgc.server.DGCImpl"); exportedDGCQueue = new ReferenceQueue<Remote>(); dgcDataTable = new DGCDataTable(); seqNumTable = new Hashtable<VMID, Pair<Long, Long>>(); timer = new Timer(true); try { timer.schedule(new CleanTask(), checkInterval, checkInterval); timer.schedule(new RipSequenceNumbersTask(), 2 * leaseProperty, 2 * leaseProperty); DGCScheduledGC.startGC(); } catch (Exception e) { // There is no chance that this try will fail unless the clean // method be errased. e.printStackTrace(); } /* * Runs the Thread that removes exported Objects out of scope and not * being used remotelly. */ this.setDaemon(true); this.start(); }
/** * @see java.rmi.dgc.DGC#clean FIXME boolean strong is not used */ public final void clean(ObjID[] ids, long sequenceNum, VMID vmid, @SuppressWarnings("unused") boolean strong) { /* * REVIEW: When the strong parameter is not setted and the VMID making * the clean call does not hold any reference to other locally exported * object the Sequence Number for that VMID could be erased. This would * require that there exists a way to recognize every ObjectID used by a * particular VMID. We have chosen not to hold that table, but instead * erase sequence Numbers for "old enough" VMID's. */ if (seqNumTable.containsKey(vmid) && sequenceNum > (Long) seqNumTable.get(vmid).getFirst()) { seqNumTable.put(vmid, new Pair<Long, Long>(new Long(sequenceNum), System.currentTimeMillis() + 2 * leaseProperty)); dgcDataTable.clean(ids, vmid); } else { // FIXME Just ignore the call? } }
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { lock = new ReentrantReadWriteLock(); lock.writeLock().lock(); try { int version = in.readInt(); int size = in.readInt(); entries = new ArrayList(size); map = new gnu.trove.TObjectIntHashMap(size); for (int i = 0; i < size; i++) { Object o = in.readObject(); map.put(o, i); entries.add(o); } growthStopped = in.readBoolean(); entryClass = (Class) in.readObject(); if (version > 0) { // instanced id added in version 1S instanceId = (VMID) in.readObject(); } } finally { lock.writeLock().unlock(); } }
/** * Starts all the periodic actions and Starts the local Garbage Collector */ public DGCImpl() { super("rmi.dgc.server.DGCImpl"); exportedDGCQueue = new ReferenceQueue<Remote>(); dgcDataTable = new DGCDataTable(); seqNumTable = new ConcurrentHashMap<VMID, Pair<Long, Long>>(); timer = new Timer("rmi.dgc.server.CleanUpTimer", true); try { timer.schedule(new CleanTask(), checkInterval, checkInterval); timer.schedule(new RipSequenceNumbersTask(), 2 * leaseProperty, 2 * leaseProperty); DGCScheduledGC.startGC(); } catch (Exception e) { // There is no chance that this try will fail unless the clean // method be errased. e.printStackTrace(); } /* * Runs the Thread that removes exported Objects out of scope and not * being used remotelly. */ this.setDaemon(true); this.start(); }
/** * A per {@link java.rmi.dgc.DGC#dirty} implementation * of the dirty method * * @param vmid * The {@link java.rmi.dgc.VMID} updated. * @param expirationTime * The time in which the lease time expires * @see java.rmi.dgc.DGC */ public final void dirty(VMID vmid, Long expirationTime) { if (vmIdExpirationTimeMap.isEmpty()) { StrongRef = weakRef.get(); if (StrongRef == null) { /* * Somehow throw an exception. There should have been a problem * in the network. */ } } if (!vmIdExpirationTimeMap.containsKey(vmid)) { dgcCount++; } vmIdExpirationTimeMap.put(vmid, expirationTime); return; }