private void checkPermits(WriteMessage e) { if (e.getMessage() instanceof Command) { Command cmd = (Command) e.getMessage(); if (cmd.isNoreply()) { int i = 3; boolean success = false; while (i-- > 0) { if (this.flowControl.aquire()) { success = true; break; } else { // reduce consuming cpu Thread.yield(); } } if (!success) throw new IllegalStateException( "No permit for noreply operation,max=" + flowControl.max()); } } }
private void releasePermit(WriteMessage rt) { if (rt != null) { if (rt.getMessage() instanceof Command) { Command cmd = (Command) rt.getMessage(); if (cmd.isNoreply()) { this.flowControl.release(); } } } }
public MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) { super(configuration, null); this.sessionLocator = locator; this.protocol = commandFactory.getProtocol(); this.addStateListener(new InnerControllerStateListener()); this.updateSessions(); this.bufferAllocator = allocator; this.optimiezer = new Optimizer(this.protocol); this.optimiezer.setBufferAllocator(this.bufferAllocator); this.connectionPoolSize = poolSize; this.soLingerOn = true; this.commandFactory = commandFactory; this.flowControl = new FlowControl(maxQueuedNoReplyOperations); this.setSelectorPoolSize(configuration.getSelectorPoolSize()); // setDispatchMessageThreadPoolSize(Runtime.getRuntime(). // availableProcessors()); }
public MemcachedConnector(Configuration configuration, MemcachedSessionLocator locator, BufferAllocator allocator, CommandFactory commandFactory, int poolSize, int maxQueuedNoReplyOperations) { super(configuration, null); this.sessionLocator = locator; this.protocol = commandFactory.getProtocol(); this.addStateListener(new InnerControllerStateListener()); this.updateSessions(); this.bufferAllocator = allocator; this.optimiezer = new Optimizer(this.protocol); this.optimiezer.setBufferAllocator(this.bufferAllocator); this.connectionPoolSize = poolSize; this.soLingerOn = true; this.commandFactory = commandFactory; this.flowControl = new FlowControl(maxQueuedNoReplyOperations); this.setSelectorPoolSize(configuration.getSelectorPoolSize()); // setDispatchMessageThreadPoolSize(Runtime.getRuntime(). // availableProcessors()); }
private void checkPermits(WriteMessage e) { if (e.getMessage() instanceof Command) { Command cmd = (Command) e.getMessage(); if (cmd.isNoreply()) { int i = 3; boolean success = false; while (i-- > 0) { if (this.flowControl.aquire()) { success = true; break; } else { // reduce consuming cpu Thread.yield(); } } if (!success) throw new IllegalStateException( "No permit for noreply operation,max=" + flowControl.max()); } } }
private void releasePermit(WriteMessage rt) { if (rt != null) { if (rt.getMessage() instanceof Command) { Command cmd = (Command) rt.getMessage(); if (cmd.isNoreply()) { this.flowControl.release(); } } } }