org.apache.catalina.tribes.util.UUIDGenerator Java Examples
The following examples show how to use
org.apache.catalina.tribes.util.UUIDGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: McastService.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public void setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort) { properties.setProperty("tcpListenHost",listenHost); properties.setProperty("tcpListenPort",String.valueOf(listenPort)); properties.setProperty("udpListenPort",String.valueOf(udpPort)); properties.setProperty("tcpSecurePort",String.valueOf(securePort)); try { if (localMember != null) { localMember.setHostname(listenHost); localMember.setPort(listenPort); } else { localMember = new MemberImpl(listenHost, listenPort, 0); localMember.setUniqueId(UUIDGenerator.randomUUID(true)); localMember.setPayload(getPayload()); localMember.setDomain(getDomain()); localMember.setLocal(true); } localMember.setSecurePort(securePort); localMember.setUdpPort(udpPort); localMember.getData(true, true); }catch ( IOException x ) { throw new IllegalArgumentException(x); } }
Example #2
Source File: MembersWithProperties.java From Tomcat8-Source-Read with MIT License | 6 votes |
@SuppressWarnings("unused") public static void main(String[] args) throws Exception { if (args.length==0) usage(); main = Thread.currentThread(); ManagedChannel channel = (ManagedChannel) ChannelCreator.createChannel(args); Properties props = new Properties(); props.setProperty("mydomainkey","mydomainvalue"); props.setProperty("someotherkey", Arrays.toString(UUIDGenerator.randomUUID(true))); new MembersWithProperties(channel, props); channel.start(Channel.DEFAULT); Runtime.getRuntime().addShutdownHook(new Shutdown(channel)); try { Thread.sleep(Long.MAX_VALUE); }catch(InterruptedException ix) { Thread.sleep(5000);//allow everything to shutdown } }
Example #3
Source File: MembersWithProperties.java From tomcatsrc with Apache License 2.0 | 6 votes |
@SuppressWarnings("unused") public static void main(String[] args) throws Exception { if (args.length==0) usage(); main = Thread.currentThread(); ManagedChannel channel = (ManagedChannel) ChannelCreator.createChannel(args); Properties props = new Properties(); props.setProperty("mydomainkey","mydomainvalue"); props.setProperty("someotherkey", Arrays.toString(UUIDGenerator.randomUUID(true))); new MembersWithProperties(channel, props); channel.start(Channel.DEFAULT); Runtime.getRuntime().addShutdownHook(new Shutdown(channel)); try { Thread.sleep(Long.MAX_VALUE); }catch(InterruptedException ix) { Thread.sleep(5000);//allow everything to shutdown } }
Example #4
Source File: McastService.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Sets the local member properties for broadcasting */ @Override public void setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort) { properties.setProperty("tcpListenHost",listenHost); properties.setProperty("tcpListenPort",String.valueOf(listenPort)); properties.setProperty("udpListenPort",String.valueOf(udpPort)); properties.setProperty("tcpSecurePort",String.valueOf(securePort)); try { if (localMember != null) { localMember.setHostname(listenHost); localMember.setPort(listenPort); } else { localMember = new MemberImpl(listenHost, listenPort, 0); localMember.setUniqueId(UUIDGenerator.randomUUID(true)); localMember.setPayload(getPayload()); localMember.setDomain(getDomain()); localMember.setLocal(true); } localMember.setSecurePort(securePort); localMember.setUdpPort(udpPort); localMember.getData(true, true); }catch ( IOException x ) { throw new IllegalArgumentException(x); } }
Example #5
Source File: McastService.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Sets the local member properties for broadcasting */ @Override public void setLocalMemberProperties(String listenHost, int listenPort, int securePort, int udpPort) { properties.setProperty("tcpListenHost",listenHost); properties.setProperty("tcpListenPort",String.valueOf(listenPort)); properties.setProperty("udpListenPort",String.valueOf(udpPort)); properties.setProperty("tcpSecurePort",String.valueOf(securePort)); try { if (localMember != null) { localMember.setHostname(listenHost); localMember.setPort(listenPort); } else { localMember = new MemberImpl(listenHost, listenPort, 0); localMember.setUniqueId(UUIDGenerator.randomUUID(true)); localMember.setPayload(getPayload()); localMember.setDomain(getDomain()); } localMember.setSecurePort(securePort); localMember.setUdpPort(udpPort); localMember.getData(true, true); }catch ( IOException x ) { throw new IllegalArgumentException(x); } }
Example #6
Source File: MembersWithProperties.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unused") public static void main(String[] args) throws Exception { if (args.length==0) usage(); main = Thread.currentThread(); ManagedChannel channel = (ManagedChannel) ChannelCreator.createChannel(args); Properties props = new Properties(); props.setProperty("mydomainkey","mydomainvalue"); props.setProperty("someotherkey", Arrays.toString(UUIDGenerator.randomUUID(true))); new MembersWithProperties(channel, props); channel.start(Channel.DEFAULT); Runtime.getRuntime().addShutdownHook(new Shutdown(channel)); try { Thread.sleep(Long.MAX_VALUE); }catch(InterruptedException ix) { Thread.sleep(5000);//allow everything to shutdown } }
Example #7
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
private CoordinationMessage createElectionMsg(Member local, Member[] others, Member leader) { Membership m = new Membership(local,AbsoluteOrder.comp,true); Arrays.fill(m,others); Member[] mbrs = m.getMembers(); m.reset(); CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST); return msg; }
Example #8
Source File: TestDomainFilterInterceptor.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { for (int i = 0; i < channels.length; i++) { channels[i] = new GroupChannel(); channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII")); listeners[i] = new TestMbrListener( ("Listener-" + (i + 1))); channels[i].addMembershipListener(listeners[i]); DomainFilterInterceptor filter = new DomainFilterInterceptor(); filter.setDomain(UUIDGenerator.randomUUID(false)); channels[i].addInterceptor(filter); } }
Example #9
Source File: TesterUtil.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Configures a set of channels to use a random domain. Use to ensure that * multiple instance of the test suite do not interfere when running on the * same machine. This may happen in a CI system or when a developer is * running tests for multiple branches in parallel. */ public static void addRandomDomain(ManagedChannel[] channels) { if (channels == null) { return; } byte[] domain = UUIDGenerator.randomUUID(false); for (ManagedChannel channel : channels) { channel.getMembershipService().setDomain(domain); DomainFilterInterceptor filter = new DomainFilterInterceptor(); filter.setDomain(domain); channel.addInterceptor(filter); } }
Example #10
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 5 votes |
private CoordinationMessage createElectionMsg(MemberImpl local, MemberImpl[] others, MemberImpl leader) { Membership m = new Membership(local,AbsoluteOrder.comp,true); Arrays.fill(m,others); MemberImpl[] mbrs = m.getMembers(); m.reset(); CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST); return msg; }
Example #11
Source File: RpcChannel.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Send a message and wait for the response. * @param destination Member[] - the destination for the message, and the members you request a reply from * @param message Serializable - the message you are sending out * @param rpcOptions int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY * @param channelOptions channel sender options * @param timeout long - timeout in milliseconds, if no reply is received within this time null is returned * @return Response[] - an array of response objects. * @throws ChannelException */ public Response[] send(Member[] destination, Serializable message, int rpcOptions, int channelOptions, long timeout) throws ChannelException { if ( destination==null || destination.length == 0 ) return new Response[0]; //avoid dead lock int sendOptions = channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK; RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false)); RpcCollector collector = new RpcCollector(key,rpcOptions,destination.length); try { synchronized (collector) { if ( rpcOptions != NO_REPLY ) responseMap.put(key, collector); RpcMessage rmsg = new RpcMessage(rpcId, key.id, message); channel.send(destination, rmsg, sendOptions); if ( rpcOptions != NO_REPLY ) collector.wait(timeout); } } catch ( InterruptedException ix ) { Thread.currentThread().interrupt(); } finally { responseMap.remove(key); } return collector.getResponses(); }
Example #12
Source File: TestDomainFilterInterceptor.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { for (int i = 0; i < channels.length; i++) { channels[i] = new GroupChannel(); channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII")); listeners[i] = new TestMbrListener( ("Listener-" + (i + 1))); channels[i].addMembershipListener(listeners[i]); DomainFilterInterceptor filter = new DomainFilterInterceptor(); filter.setDomain(UUIDGenerator.randomUUID(false)); channels[i].addInterceptor(filter); } }
Example #13
Source File: TesterUtil.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Configures a set of channels to use a random domain. Use to ensure that * multiple instance of the test suite do not interfere when running on the * same machine. This may happen in a CI system or when a developer is * running tests for multiple branches in parallel. */ public static void addRandomDomain(ManagedChannel[] channels) { if (channels == null) { return; } byte[] domain = UUIDGenerator.randomUUID(false); for (ManagedChannel channel : channels) { channel.getMembershipService().setDomain(domain); DomainFilterInterceptor filter = new DomainFilterInterceptor(); filter.setDomain(domain); channel.addInterceptor(filter); } }
Example #14
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private CoordinationMessage createElectionMsg(MemberImpl local, MemberImpl[] others, MemberImpl leader) { Membership m = new Membership(local,AbsoluteOrder.comp,true); Arrays.fill(m,others); MemberImpl[] mbrs = m.getMembers(); m.reset(); CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST); return msg; }
Example #15
Source File: RpcChannel.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Send a message and wait for the response. * @param destination Member[] - the destination for the message, and the members you request a reply from * @param message Serializable - the message you are sending out * @param rpcOptions int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY * @param channelOptions channel sender options * @param timeout long - timeout in milliseconds, if no reply is received within this time null is returned * @return Response[] - an array of response objects. * @throws ChannelException */ public Response[] send(Member[] destination, Serializable message, int rpcOptions, int channelOptions, long timeout) throws ChannelException { if ( destination==null || destination.length == 0 ) return new Response[0]; //avoid dead lock int sendOptions = channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK; RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false)); RpcCollector collector = new RpcCollector(key,rpcOptions,destination.length); try { synchronized (collector) { if ( rpcOptions != NO_REPLY ) responseMap.put(key, collector); RpcMessage rmsg = new RpcMessage(rpcId, key.id, message); channel.send(destination, rmsg, sendOptions); if ( rpcOptions != NO_REPLY ) collector.wait(timeout); } } catch ( InterruptedException ix ) { Thread.currentThread().interrupt(); }finally { responseMap.remove(key); } return collector.getResponses(); }
Example #16
Source File: TestDomainFilterInterceptor.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Before public void setUp() throws Exception { for (int i = 0; i < channels.length; i++) { channels[i] = new GroupChannel(); channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII")); listeners[i] = new TestMbrListener( ("Listener-" + (i + 1))); channels[i].addMembershipListener(listeners[i]); DomainFilterInterceptor filter = new DomainFilterInterceptor(); filter.setDomain(UUIDGenerator.randomUUID(false)); channels[i].addInterceptor(filter); } }
Example #17
Source File: TesterUtil.java From Tomcat8-Source-Read with MIT License | 5 votes |
public static void addRandomDomain(ManagedChannel[] channels) { if (channels == null) { return; } byte[] domain = UUIDGenerator.randomUUID(false); for (ManagedChannel channel : channels) { channel.getMembershipService().setDomain(domain); DomainFilterInterceptor filter = new DomainFilterInterceptor(); filter.setDomain(domain); channel.addInterceptor(filter); } }
Example #18
Source File: RpcChannel.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Send a message and wait for the response. * @param destination Member[] - the destination for the message, and the members you request a reply from * @param message Serializable - the message you are sending out * @param rpcOptions int - FIRST_REPLY, MAJORITY_REPLY or ALL_REPLY * @param channelOptions channel sender options * @param timeout long - timeout in milliseconds, if no reply is received within this time null is returned * @return Response[] - an array of response objects. * @throws ChannelException Error sending message */ public Response[] send(Member[] destination, Serializable message, int rpcOptions, int channelOptions, long timeout) throws ChannelException { if ( destination==null || destination.length == 0 ) return new Response[0]; //avoid dead lock int sendOptions = channelOptions & ~Channel.SEND_OPTIONS_SYNCHRONIZED_ACK; RpcCollectorKey key = new RpcCollectorKey(UUIDGenerator.randomUUID(false)); RpcCollector collector = new RpcCollector(key,rpcOptions,destination.length); try { synchronized (collector) { if ( rpcOptions != NO_REPLY ) responseMap.put(key, collector); RpcMessage rmsg = new RpcMessage(rpcId, key.id, message); channel.send(destination, rmsg, sendOptions); if ( rpcOptions != NO_REPLY ) collector.wait(timeout); } } catch ( InterruptedException ix ) { Thread.currentThread().interrupt(); } finally { responseMap.remove(key); } return collector.getResponses(); }
Example #19
Source File: ChannelData.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Generates a UUID and invokes setUniqueId */ public void generateUUID() { byte[] data = new byte[16]; UUIDGenerator.randomUUID(USE_SECURE_RANDOM_FOR_UUID,data,0); setUniqueId(data); }
Example #20
Source File: ChannelData.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Generates a UUID and invokes setUniqueId */ public void generateUUID() { byte[] data = new byte[16]; UUIDGenerator.randomUUID(USE_SECURE_RANDOM_FOR_UUID,data,0); setUniqueId(data); }
Example #21
Source File: ChannelData.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Generates a UUID and invokes setUniqueId */ public void generateUUID() { byte[] data = new byte[16]; UUIDGenerator.randomUUID(USE_SECURE_RANDOM_FOR_UUID,data,0); setUniqueId(data); }