public int hashCode(int position) { int result = 0; for (ChannelBuilder channel : channels) { result = addToHashCode(result, channel.hashCode(position)); } return result; }
public long getMemorySize() { long memorySize = 0; for (ChannelBuilder channel : channels) { memorySize += channel.getMemorySize(); } return memorySize; }
public boolean equals(int position, BlockCursor... row) { for (int i = 0; i < channels.size(); i++) { ChannelBuilder thisBlock = this.channels.get(i); if (!thisBlock.equals(position, row[i])) { return false; } } return true; }
public boolean equals(int thisPosition, GroupByPageBuilder that, int thatPosition) { for (int i = 0; i < channels.size(); i++) { ChannelBuilder thisBlock = this.channels.get(i); ChannelBuilder thatBlock = that.channels.get(i); if (!thisBlock.equals(thisPosition, thatBlock, thatPosition)) { return false; } } return true; }
/*package*/ Channel(ChannelBuilder settings, CommandTransport transport) throws IOException { this.name = settings.getName(); this.executor = new InterceptingExecutorService(settings.getExecutors()); this.isRestricted = settings.isRestricted(); this.underlyingOutput = transport.getUnderlyingStream(); this.jarCache = settings.getJarCache(); this.baseClassLoader = settings.getBaseLoader(); if (export(this, false) != 1) throw new AssertionError(); // export number 1 is reserved for the channel itself remoteChannel = RemoteInvocationHandler.wrap(this, 1, IChannel.class, true, false); this.remoteCapability = transport.getRemoteCapability(); this.pipeWriter = new PipeWriter(createPipeWriterExecutor()); this.transport = transport; this.jarLoader = new JarLoaderImpl(); // TODO: figure out a mechanism to allow the user to share this across // Channels setProperty(JarLoader.OURS, export(JarLoader.class, jarLoader, false)); transport.setup( this, new CommandReceiver() { public void handle(Command cmd) { lastHeard = System.currentTimeMillis(); if (logger.isLoggable(Level.FINE)) logger.fine("Received " + cmd); try { cmd.execute(Channel.this); } catch (Throwable t) { logger.log( Level.SEVERE, "Failed to execute command " + cmd + " (channel " + Channel.this.name + ")", t); logger.log(Level.SEVERE, "This command is created here", cmd.createdAt); } } public void terminate(IOException e) { Channel.this.terminate(e); } }); }
/*package*/ Channel(ChannelBuilder settings, InputStream is, OutputStream os) throws IOException { this(settings, settings.negotiate(is, os)); }
public void appendValuesTo(int position, BlockBuilder[] builders) { for (int i = 0; i < channels.size(); i++) { ChannelBuilder channel = channels.get(i); channel.appendTo(position, builders[i]); } }