Initialize this channel object for writing.

@throws IOException
425879
public void initialize() throws IOException {
    // Create a pipe such that its one end is connected to the input stream used by
    // the uploader and the other end is the write channel used by the caller.
    PipedInputStream pipeSource = new PipedInputStream(pipeBufferSize);
    OutputStream pipeSink = new PipedOutputStream(pipeSource);
    pipeSinkChannel = Channels.newChannel(pipeSink);

    // Connect pipe-source to the stream used by uploader.
    InputStreamContent objectContentStream = new InputStreamContent(contentType, pipeSource);
    // Indicate that we do not know length of file in advance.
    objectContentStream.setLength(-1);
    objectContentStream.setCloseInputStream(false);

    T request = createRequest(objectContentStream);
    request.setDisableGZipContent(true);

    // Change chunk size from default value (10MB) to one that yields higher performance.
    clientRequestHelper.setChunkSize(request, uploadChunkSize);

    // Given that the two ends of the pipe must operate asynchronous relative
    // to each other, we need to start the upload operation on a separate thread.
    uploadOperation = threadPool.submit(new UploadOperation(request, pipeSource));

    isInitialized = true;
  }
1362851
public void init() throws ChannelException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "UDP Channel: " + getConfig().getExternalName() + " listening port: " + String.valueOf(getConfig().getPort()));
        }
    }
979796
public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());
    out.writeInt(_value.length);
    out.write(_value, 0, _value.length);
  }
102104
public void init() throws IOException {
    Injector injector = Guice.createInjector(
        new ConfigModule(conf),
        new ZKModule(),
        new DiscoveryModules().getDistributedModules(),
        new TransactionModules().getDistributedModules(),
        new TransactionClientModule()
    );

    zkClient = injector.getInstance(ZKClientService.class);
    zkClient.startAndWait();
    txClient = injector.getInstance(TransactionServiceClient.class);

    createTableIfNotExists(conf, TABLE, new byte[][]{ FAMILY });
    conn = HConnectionManager.createConnection(conf);
  }
1174723
public void initialize() {
        try {
            writeLock.lock();
            if (!isInitialized()) {
                super.initialize();
                setInitialized(true);
                this.initCalled = true;
            }
        } finally {
            // downgrade to readlock before releasing just in case
            readLock.lock();
            writeLock.unlock();
            readLock.unlock();
        }
    }
327303
@Override
  public void init() {
    if (!getProcessContext().inheritsIO()) {
      newThread(String.format("Process [%d] Standard Out Reader", safeGetId()),
        newProcessStreamReader(getProcess().getInputStream())).start();

      if (!getProcessContext().isRedirectingErrorStream()) {
        newThread(String.format("Process [%d] Standard Error Reader", safeGetId()),
          newProcessStreamReader(getProcess().getErrorStream())).start();
      }
    }

    initialized.set(true);
  }
730730
private void initStream() throws IOException {

        if (m_out == null) {
            if (!m_writeOnlyToBuffer) {
                // we can use the parents output stream
                if (m_cachingRequired || (m_controller.getResponseStackSize() > 1)) {
                    // we are allowed to cache our results (probably to construct a new cache entry)
                    m_out = new CmsFlexResponse.CmsServletOutputStream(m_res.getOutputStream());
                } else {
                    // we are not allowed to cache so we just use the parents output stream
                    m_out = (CmsFlexResponse.CmsServletOutputStream)m_res.getOutputStream();
                }
            } else {
                // construct a "buffer only" output stream
                m_out = new CmsFlexResponse.CmsServletOutputStream();
            }
        }
        if (m_writer == null) {
            // create a PrintWriter that uses the encoding required for the request context
            m_writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(m_out, m_encoding)), false);
        }
    }
93188
public void initiate() throws IOException
    {
        logger.debug("[Stream #{}] Sending stream init for incoming stream", session.planId());
        Socket incomingSocket = session.createConnection();
        incoming.start(incomingSocket, StreamMessage.CURRENT_VERSION);
        incoming.sendInitMessage(incomingSocket, true);

        logger.debug("[Stream #{}] Sending stream init for outgoing stream", session.planId());
        Socket outgoingSocket = session.createConnection();
        outgoing.start(outgoingSocket, StreamMessage.CURRENT_VERSION);
        outgoing.sendInitMessage(outgoingSocket, false);
    }
1374198
private void init() {
        cacheable = null;
        status = SC_OK;
        cachedResponse = cached.createCachedResponse();
        streamDelegate = new ServletResponseStreamDelegate(this) {
            protected OutputStream createOutputStream() throws IOException {
                // Test if this request is really cacheable, otherwise,
                // just write through to underlying response, and don't cache
                if (isCacheable()) {
                    return cachedResponse.getOutputStream();
                }
                else {
                    cachedResponse.setStatus(status);
                    cachedResponse.writeHeadersTo(CacheResponseWrapper.this.response);
                    return super.getOutputStream();
                }
            }
        };
    }
83814
@Process(actionType = InitBatch.class)
    public void init(final Dispatcher.Channel channel) {
        List<ModelNode> steps = new ArrayList<>();
        steps.add(readResourceOp(BATCH_ADDRESS));
        steps.add(readResourceOp(THREAD_POOL_ADDRESS));
        steps.add(readResourceOp(JOB_REPOSITORY_ADDRESS));
        steps.add(readThreadFactoriesOp());

        final ModelNode comp = new ModelNode();
        comp.get(ADDRESS).setEmptyList();
        comp.get(OP).set(COMPOSITE);
        comp.get(STEPS).set(steps);

        dispatcher.execute(new DMRAction(comp), new AsyncCallback<DMRResponse>() {
            @Override
            public void onFailure(Throwable caught) {
                channel.nack(caught);
            }

            @Override
            public void onSuccess(DMRResponse dmrResponse) {
                ModelNode response = dmrResponse.get();
                if (response.isFailure()) {
                    channel.nack(new RuntimeException("Failed to initialize batch store using " + comp + ": " +
                            response.getFailureDescription()));
                } else {
                    ModelNode result = response.get(RESULT);
                    ModelNode stepResult = result.get("step-1");
                    if (stepResult.get(RESULT).isDefined()) {
                        batch = stepResult.get(RESULT);
                    }
                    stepResult = result.get("step-2");
                    if (stepResult.get(RESULT).isDefined()) {
                        threadPool = stepResult.get(RESULT);
                    }
                    stepResult = result.get("step-3");
                    if (stepResult.get(RESULT).isDefined()) {
                        jobRepository = stepResult.get(RESULT);
                    }
                    stepResult = result.get("step-4");
                    if (stepResult.get(RESULT).isDefined()) {
                        threadFactories.clear();
                        threadFactories.addAll(stepResult.get(RESULT).asPropertyList());
                    }
                    channel.ack();
                }
            }
        });
    }
59692
protected void setupQueue() throws IOException {
		if (queueName != null) {
			channel.queueDeclare(queueName, false, false, false, null);
		}
	}
1351757
private void init(String command, Socket socket) throws IOException {
        lock.lock();
        try {
            initTokens = new Hashtable<String, Integer>();

            DataOutputStream dout = new DataOutputStream(socket.getOutputStream());
            dout.writeInt(BYTES_INT);
            dout.writeInt(1);
            dout.flush();
        } finally {
            lock.unlock();
        }
    }
322374
public void sendData() throws IOException {
        if (writer != null) {
            writer.write(buffer.toString());
            writer.flush();
            buffer = new StringBuilder();
        }
    }
859470
public void write() {
    // We record the start time to avoid spending too much time on writings
    long startOfCycle = System.nanoTime();
    long bytesWritten = 0;

    long nPacketsWritten = 0;

    while ((System.nanoTime() - startOfCycle - writeBatchTime.toNanos()) < 0
        && (bytesWritten < writeBatchSize.asBytes())) {
      OutgoingPacket outgoingPacket = outgoingPacketsToWrite.peek();
      if (outgoingPacket == null) {
        break;
      }

      int writeState = outgoingPacket.writeToChannel(socketChannel);
      if (writeState > 0) {
        // Partial writing, we would break since we could not write more data on socket.
        // But we have set the next start point of OutgoingPacket
        // Next time when the socket is writable, it will start from that point.
        break;
      } else if (writeState < 0) {
        LOG.severe("Something bad happened while writing to channel");
        selectHandler.handleError(socketChannel);
        return;
      } else {
        // writeState == 0, we fully write a outgoingPacket
        bytesWritten += outgoingPacket.size();
        nPacketsWritten++;

        outgoingPacketsToWrite.remove();
      }
    }

    totalPacketsWritten += nPacketsWritten;
    totalBytesWritten += bytesWritten;

    // Disable writing if there are nothing to send in buffer
    if (getOutstandingPackets() == 0) {
      disableWriting();
    }
  }
331136
@Override
    public void write(int b) throws IOException {
        if (this.isClosed) {
            throw new IOException("OutputStream is closed.");
        }

        if (this.position >= this.length) {
            throw new IOException("Buffer capacity exceeded.");
        }

        this.array[this.offset + this.position] = (byte) b;
        this.position++;
    }
1368019
public void write(Writer out)
         throws IOException
    {
        out.write("<!--\n");
        super.write(out);
        out.write("\n-->");
    }
1195889
private void writeObject(ObjectOutputStream out) throws IOException {
        out.defaultWriteObject();
        out.writeUTF(params.getId());
    }