public static BrokerFactoryHandler createBrokerFactoryHandler(String type) throws IOException { try { return (BrokerFactoryHandler)BROKER_FACTORY_HANDLER_FINDER.newInstance(type); } catch (Throwable e) { throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e); } }
/** * Performs the given code to stop some service handling the exceptions * which may be thrown properly */ public void run(Callback stopClosure) { try { stopClosure.execute(); } catch (Throwable e) { onException(stopClosure, e); } }
public void rollback(final String id) { String seed = IdGenerator.getSeedFromId(id); if (seed != null) { BitArrayBin bab = map.get(seed); if (bab != null) { long index = IdGenerator.getSequenceFromId(id); bab.setBit(index, false); modified = true; } } }
protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { CompositeData data = URISupport.parseComposite(uri); Map options = data.getParameters(); SimpleDiscoveryAgent rc = new SimpleDiscoveryAgent(); IntrospectionSupport.setProperties(rc, options); rc.setServices(data.getComponents()); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
@Override public void stop() throws Exception { ServiceStopper ss = new ServiceStopper(); ss.stop(discoveryAgent); ss.stop(next); ss.throwFirstException(); }
public static void writeShortLittle(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 2); write(packet, (v >>> 0) & 0xFF); write(packet, (v >>> 8) & 0xFF); }
public static long readLongLittle(ByteSequence packet) throws IOException { spaceNeeded(packet, 8); return (read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + ((long)read(packet) << 24) + ((long)read(packet) << 32) + ((long)read(packet) << 40) + ((long)read(packet) << 48) + ((long)read(packet) << 56); }
public Future<T> future() { if( future == null ) { PromiseFuture future = new PromiseFuture(); watch(future); this.future = future; } return future; }
/** * start using a fresh byte array */ public void restart() { restart(DEFAULT_SIZE); }
public int hashCode() { if (hash == 0) { hash = formatId; JenkinsHash jh = JenkinsHash.getInstance(); hash = jh.hash(globalTransactionId, hash); hash = jh.hash(branchQualifier, hash); if (hash == 0) { hash = 0xaceace; } } return hash; }
public IntSequenceGenerator getSequenceGenerator() { if (sequenceGenerator == null) { sequenceGenerator = new IntSequenceGenerator(); } return sequenceGenerator; }
/** * @param context * @param originalMessage * @param deadLetterDestination * @throws Exception */ public static void resend(final ConnectionContext context, Message originalMessage, ActiveMQDestination deadLetterDestination) throws Exception { doResend(context, originalMessage, deadLetterDestination, true); }
/** * Writes the specified byte to this byte array output stream. * * @param b the byte to be written. */ public void write(int b) { int newcount = pos + 1; ensureEnoughBuffer(newcount); buf[pos] = (byte)b; pos = newcount; }
public char readChar() throws IOException { int ch1 = readOrIOException(); int ch2 = readOrIOException(); return (char)((ch1 << 8) + (ch2 << 0)); }
public SocketProxy(int port, URI uri) throws Exception { listenPort = port; target = uri; open(); }
@Override protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException { try { CompositeData data = URISupport.parseComposite(uri); Map options = data.getParameters(); MasterSlaveDiscoveryAgent rc = new MasterSlaveDiscoveryAgent(); IntrospectionSupport.setProperties(rc, options); rc.setServices(data.getComponents()); return rc; } catch (Throwable e) { throw IOExceptionSupport.create("Could not create discovery agent: " + uri, e); } } }
public static void writeIntLittle(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 4); write(packet, (v >>> 0) & 0xFF); write(packet, (v >>> 8) & 0xFF); write(packet, (v >>> 16) & 0xFF); write(packet, (v >>> 24) & 0xFF); }
public static void writeLongBig(ByteSequence packet, long v) throws IOException { spaceNeeded(packet, 8); write(packet, (int)(v >>> 56) & 0xFF); write(packet, (int)(v >>> 48) & 0xFF); write(packet, (int)(v >>> 40) & 0xFF); write(packet, (int)(v >>> 32) & 0xFF); write(packet, (int)(v >>> 24) & 0xFF); write(packet, (int)(v >>> 16) & 0xFF); write(packet, (int)(v >>> 8) & 0xFF); write(packet, (int)(v >>> 0) & 0xFF); }