/** * Performs the flush of the given channel within the specfied number of attempts along with random * sleep time after each such attempt. * @param c the channel * @param numberOfAttempts the number of flush attempts * @param randomSleepTimeoutFloor the minimum sleep time between attempts in ms * @param randomSleepTimeoutCeiling the maximum sleep time between attempts in ms * @return true if channel was flushed successfully, false otherwise * @see JChannel#startFlush(boolean) */ public static boolean startFlush(JChannel c,int numberOfAttempts,long randomSleepTimeoutFloor,long randomSleepTimeoutCeiling) { int attemptCount=0; while(attemptCount < numberOfAttempts) { try { c.startFlush(false); return true; } catch(Exception e) { Util.sleepRandom(randomSleepTimeoutFloor,randomSleepTimeoutCeiling); attemptCount++; } } return false; }
/** * Performs the flush of the given channel for the specified flush participants and the given * number of attempts along with random sleep time after each such attempt. * @param c the channel * @param flushParticipants the flush participants in this flush attempt * @param numberOfAttempts the number of flush attempts * @param randomSleepTimeoutFloor the minimum sleep time between attempts in ms * @param randomSleepTimeoutCeiling the maximum sleep time between attempts in ms * @return true if channel was flushed successfully, false otherwise * @see JChannel#startFlush(List,boolean) */ public static boolean startFlush(JChannel c,List<Address> flushParticipants, int numberOfAttempts,long randomSleepTimeoutFloor,long randomSleepTimeoutCeiling) { int attemptCount=0; while(attemptCount < numberOfAttempts) { try { c.startFlush(flushParticipants,false); return true; } catch(Exception e) { Util.sleepRandom(randomSleepTimeoutFloor,randomSleepTimeoutCeiling); attemptCount++; } } return false; }
while (attemptCount < maxAttempts) { if (attemptCount > 0) Util.sleepRandom(randomFloor, randomCeiling); try { up_prot.up(new Event(Event.SUSPEND, new ArrayList<>(new_view.getMembers())));
protected void applyNewConfig(byte[] buffer) { final InputStream in=new ByteArrayInputStream(buffer); Thread thread=new Thread(() -> { try { JChannel ch=new JChannel(in); Util.sleepRandom(1000, 5000); channel.disconnect(); JChannel tmp=channel; channel=ch; channel.setName(name); channel.setReceiver(MPerf.this); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.unregisterChannel(tmp, Util.getMBeanServer(), "jgroups", "mperf"); Util.close(tmp); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); } catch(Exception e) { System.err.println("failed creating new channel"); } }); System.out.println("<< restarting channel"); thread.start(); }
protected void handleEvent(Event evt) { switch(evt.getType()) { case Event.VIEW_CHANGE: View old_view=view, new_view=evt.getArg(); this.view=new_view; if(old_view == null) { // first join Util.sleepRandom(0, stagger_timeout); // 1. send my own mapping to all multicastOwnMapping(); // 2. ask the coordinator to send us the cache contents Address coord=new_view.getCoord(); if(Objects.equals(local_addr, coord)) return; Message msg=new Message(coord).setFlag(Message.Flag.OOB).putHeader(id, new Header(Type.CACHE_REQ)); down_prot.down(msg); return; } if(new_view instanceof MergeView) { Util.sleepRandom(0, stagger_timeout); multicastOwnMapping(); } break; case Event.SET_LOCAL_ADDRESS: local_addr=evt.getArg(); break; } }
/** * Performs the flush of the given channel within the specfied number of attempts along with random * sleep time after each such attempt. * @param c the channel * @param numberOfAttempts the number of flush attempts * @param randomSleepTimeoutFloor the minimum sleep time between attempts in ms * @param randomSleepTimeoutCeiling the maximum sleep time between attempts in ms * @return true if channel was flushed successfully, false otherwise * @see JChannel#startFlush(boolean) */ public static boolean startFlush(JChannel c,int numberOfAttempts,long randomSleepTimeoutFloor,long randomSleepTimeoutCeiling) { int attemptCount=0; while(attemptCount < numberOfAttempts) { try { c.startFlush(false); return true; } catch(Exception e) { Util.sleepRandom(randomSleepTimeoutFloor,randomSleepTimeoutCeiling); attemptCount++; } } return false; }
/** * Performs the flush of the given channel for the specified flush participants and the given * number of attempts along with random sleep time after each such attempt. * @param c the channel * @param flushParticipants the flush participants in this flush attempt * @param numberOfAttempts the number of flush attempts * @param randomSleepTimeoutFloor the minimum sleep time between attempts in ms * @param randomSleepTimeoutCeiling the maximum sleep time between attempts in ms * @return true if channel was flushed successfully, false otherwise * @see JChannel#startFlush(List,boolean) */ public static boolean startFlush(JChannel c,List<Address> flushParticipants, int numberOfAttempts,long randomSleepTimeoutFloor,long randomSleepTimeoutCeiling) { int attemptCount=0; while(attemptCount < numberOfAttempts) { try { c.startFlush(flushParticipants,false); return true; } catch(Exception e) { Util.sleepRandom(randomSleepTimeoutFloor,randomSleepTimeoutCeiling); attemptCount++; } } return false; }
while (attemptCount < maxAttempts) { if (attemptCount > 0) Util.sleepRandom(randomFloor, randomCeiling); try { up_prot.up(new Event(Event.SUSPEND, new ArrayList<>(new_view.getMembers())));
protected void applyNewConfig(byte[] buffer) { final InputStream in=new ByteArrayInputStream(buffer); Thread thread=new Thread(() -> { try { JChannel ch=new JChannel(in); Util.sleepRandom(1000, 5000); channel.disconnect(); JChannel tmp=channel; channel=ch; channel.setName(name); channel.setReceiver(MPerf.this); channel.connect("mperf"); local_addr=channel.getAddress(); JmxConfigurator.unregisterChannel(tmp, Util.getMBeanServer(), "jgroups", "mperf"); Util.close(tmp); JmxConfigurator.registerChannel(channel, Util.getMBeanServer(), "jgroups", "mperf", true); } catch(Exception e) { System.err.println("failed creating new channel"); } }); System.out.println("<< restarting channel"); thread.start(); }
protected void handleEvent(Event evt) { switch(evt.getType()) { case Event.VIEW_CHANGE: View old_view=view, new_view=evt.getArg(); this.view=new_view; if(old_view == null) { // first join Util.sleepRandom(0, stagger_timeout); // 1. send my own mapping to all multicastOwnMapping(); // 2. ask the coordinator to send us the cache contents Address coord=new_view.getCoord(); if(Objects.equals(local_addr, coord)) return; Message msg=new Message(coord).setFlag(Message.Flag.OOB).putHeader(id, new Header(Type.CACHE_REQ)); down_prot.down(msg); return; } if(new_view instanceof MergeView) { Util.sleepRandom(0, stagger_timeout); multicastOwnMapping(); } break; case Event.SET_LOCAL_ADDRESS: local_addr=evt.getArg(); break; } }