public CallbackConnection(MQTT mqtt) { this.mqtt = mqtt; if(this.mqtt.dispatchQueue == null) { this.queue = createQueue("mqtt client"); } else { this.queue = this.mqtt.dispatchQueue; } }
public void run() { dispatchSource = Dispatch.createSource(EventAggregators.linkedList(), dispatchQueue); dispatchSource.setEventHandler(new Runnable() { public void run() {
static protected void assertNotOnDispatchQueue() { assert Dispatch.getCurrentQueue()==null : "Not allowed to be called when executing on a dispatch queue"; }
protected void onConnected() throws IOException { readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue); readSource.setCancelHandler(CANCEL_HANDLER); writeSource.setCancelHandler(CANCEL_HANDLER); readSource.setEventHandler(new Runnable() { public void run() { drainInbound(); } }); writeSource.setEventHandler(new Runnable() { public void run() { drainOutbound(); } }); if( max_read_rate!=0 || max_write_rate!=0 ) { rateLimitingChannel = new RateLimitingChannel(); schedualRateAllowanceReset(); } remoteAddress = channel.socket().getRemoteSocketAddress().toString(); listener.onTransportConnected(this); }
@Override protected ResponseFuture createResponse(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args) throws Exception { return new AsyncResponseFuture(loader, method, (AsyncCallback) args[args.length-1], serializationStrategy, Dispatch.getCurrentQueue()); }
public MqttSession(HostState host_state, UTF8Buffer client_id, SessionState session_state) { this.host_state = host_state; this.client_id = client_id; this.queue = createQueue("mqtt: " + client_id); this.session_state = session_state; }
protected void onConnected() throws IOException { readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue); readSource.setCancelHandler(CANCEL_HANDLER); writeSource.setCancelHandler(CANCEL_HANDLER); readSource.setEventHandler(new Runnable() { public void run() { drainInbound(); } }); writeSource.setEventHandler(new Runnable() { public void run() { drainOutbound(); } }); if( max_read_rate!=0 || max_write_rate!=0 ) { rateLimitingChannel = new RateLimitingChannel(); schedualRateAllowanceReset(); } remoteAddress = channel.socket().getRemoteSocketAddress().toString(); listener.onTransportConnected(this); }
@Override protected ResponseFuture createResponse(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args) throws Exception { return new AsyncResponseFuture(loader, method, serializationStrategy, Dispatch.getCurrentQueue()); }
public CallbackConnection(MQTT mqtt) { this.mqtt = mqtt; if(this.mqtt.dispatchQueue == null) { this.queue = createQueue("mqtt client"); } else { this.queue = this.mqtt.dispatchQueue; } }
protected void onConnected() throws IOException { yieldSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); yieldSource.setEventHandler(new Task() { public void run() { drainOutboundSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); drainOutboundSource.setEventHandler(new Task() { public void run() { drainOutboundSource.resume(); readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue);
@Override protected ResponseFuture createResponse(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args) throws Exception { return new AsyncResponseFuture(loader, method, serializationStrategy, Dispatch.getCurrentQueue()); }
public Manager(BundleContext context, CuratorFramework curator, String uri, String exportedAddress, long timeout) throws Exception { this.queue = Dispatch.createQueue(); this.importedServices = new ConcurrentHashMap<EndpointDescription, Map<Long, ImportRegistration>>(); this.exportedServices = new ConcurrentHashMap<ServiceReference, ExportRegistration>(); this.listeners = new ConcurrentHashMap<ListenerInfo, SimpleFilter>(); this.serializationStrategies = new ConcurrentHashMap<String, SerializationStrategy>(); this.remoteEndpoints = new CapabilitySet<EndpointDescription>( Arrays.asList(Constants.OBJECTCLASS, ENDPOINT_FRAMEWORK_UUID), false); this.bundleContext = context; this.curator = curator; this.uri = uri; this.exportedAddress = exportedAddress; this.timeout = timeout; }
public AggregatingExecutor(DispatchQueue queue) { this.queue = queue; this.source = createSource(EventAggregators.<Runnable>linkedList(), queue); this.source.setEventHandler(new Task() { public void run() { for (Runnable runnable: source.getData() ) { try { runnable.run(); } catch (Exception e) { Thread thread = Thread.currentThread(); thread.getUncaughtExceptionHandler().uncaughtException(thread, e); } } } }); this.source.resume(); }
protected void fireWatches() { if( !this.watches.isEmpty() ) { Dispatch.getCurrentQueue().execute(new Task(){ @Override public void run() { // Lets see if any of the watches are triggered. LinkedList<Watch> tmp = watches; watches = new LinkedList<Watch>(); for (Watch task : tmp) { if( !task.execute() ) { watches.add(task); } } } }); } }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { this.queue = Dispatch.createQueue(getComponentId().toString()); this.mqtt = MqttLifecycleComponent.configure(this, queue); }
acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue); acceptSource.setEventHandler(new Runnable() { public void run() {
public ResponseFuture request(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args, DataByteArrayOutputStream target) throws Exception { assert Dispatch.getCurrentQueue() == null : "You should not do blocking RPC class when executing on a dispatch queue"; serializationStrategy.encodeRequest(loader, method.getParameterTypes(), args, target); return new BlockingResponseFuture(loader, method, serializationStrategy); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { this.queue = Dispatch.createQueue(getComponentId()); this.mqtt = MqttLifecycleComponent.configure(this, queue); }
acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue); acceptSource.setEventHandler(new Task() { public void run() {
public ResponseFuture request(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args, DataByteArrayOutputStream target) throws Exception { if(!isAsyncMethod(method)) { throw new IllegalArgumentException("Invalid async method declaration: last argument is not a RequestCallback"); } Class[] new_types = payloadTypes(method); Object[] new_args = new Object[args.length-1]; System.arraycopy(args, 0, new_args, 0, new_args.length); serializationStrategy.encodeRequest(loader, new_types, new_args, target); return new AsyncResponseFuture(loader, method, (AsyncCallback) args[args.length-1], serializationStrategy, Dispatch.getCurrentQueue()); }