Connect.

@param configuration the connection configuration
@return the future connection
@throws IOException
10938
public static IoFuture<Connection> connect(final ProtocolConnectionConfiguration configuration) throws IOException {
        return connect(configuration.getCallbackHandler(), configuration);
    }
383098
public void connectServer(Connection connection) {
    threadContext.checkThread();

    // Handlers for all request types are registered since requests can be proxied between servers.
    // Note we do not use method references here because the "state" variable changes over time.
    // We have to use lambdas to ensure the request handler points to the current state.
    connection.handler(RegisterRequest.class, (Function<RegisterRequest, CompletableFuture<RegisterResponse>>) request -> state.register(request));
    connection.handler(ConnectRequest.class, (Function<ConnectRequest, CompletableFuture<ConnectResponse>>) request -> state.connect(request, connection));
    connection.handler(KeepAliveRequest.class, (Function<KeepAliveRequest, CompletableFuture<KeepAliveResponse>>) request -> state.keepAlive(request));
    connection.handler(UnregisterRequest.class, (Function<UnregisterRequest, CompletableFuture<UnregisterResponse>>) request -> state.unregister(request));
    connection.handler(ResetRequest.class, (Consumer<ResetRequest>) request -> state.reset(request));
    connection.handler(ConfigureRequest.class, (Function<ConfigureRequest, CompletableFuture<ConfigureResponse>>) request -> state.configure(request));
    connection.handler(InstallRequest.class, (Function<InstallRequest, CompletableFuture<InstallResponse>>) request -> state.install(request));
    connection.handler(JoinRequest.class, (Function<JoinRequest, CompletableFuture<JoinResponse>>) request -> state.join(request));
    connection.handler(ReconfigureRequest.class, (Function<ReconfigureRequest, CompletableFuture<ReconfigureResponse>>) request -> state.reconfigure(request));
    connection.handler(LeaveRequest.class, (Function<LeaveRequest, CompletableFuture<LeaveResponse>>) request -> state.leave(request));
    connection.handler(AppendRequest.class, (Function<AppendRequest, CompletableFuture<AppendResponse>>) request -> state.append(request));
    connection.handler(PollRequest.class, (Function<PollRequest, CompletableFuture<PollResponse>>) request -> state.poll(request));
    connection.handler(VoteRequest.class, (Function<VoteRequest, CompletableFuture<VoteResponse>>) request -> state.vote(request));
    connection.handler(CommandRequest.class, (Function<CommandRequest, CompletableFuture<CommandResponse>>) request -> state.command(request));
    connection.handler(QueryRequest.class, (Function<QueryRequest, CompletableFuture<QueryResponse>>) request -> state.query(request));

    connection.onClose(stateMachine.executor().context().sessions()::unregisterConnection);
  }
1189717
public final static String process(final File file, final Configuration configuration) throws IOException
    {
        final FileInputStream input = new FileInputStream(file);
        final String ret = process(input, configuration);
        input.close();
        return ret;
    }
39501
private void configure(Map<String, Object> configuration) throws IOException {
        List<TaskConfig> configList = new ArrayList<TaskConfig>();
        configList.addAll(parseConfig(configuration));
        for (TaskConfig taskConfig : configList) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Task config " + this, taskConfig);
            }
            if (taskConfig.getEnabled()) {
                //Create the task, set the configuration and add it to the map if it's not already present.
                Task task = new TaskImpl();
                if (task != null) {
                    //Check if task already exist (by check if the source id is already in the taskMap)
                    //if not, we set the task with the new config and get appropriate handler based on the type of source
                    //else, we simply replace the config in the original task with the modified config
                    if (!taskMap.containsKey(taskConfig.sourceId())) {
                        task.setHandlerName(getHandlerName());
                        task.setConfig(taskConfig);
                        taskMap.putIfAbsent(taskConfig.sourceId(), task);
                    } else {
                        taskMap.get(taskConfig.sourceId()).setConfig(taskConfig);
                    }
                }
            }
        }
    }
448751
protected void connect(String host, int port)
        throws UnknownHostException, IOException
    {
        boolean connected = false;
        try {
            InetAddress address = InetAddress.getByName(host);
            this.port = port;
            this.address = address;

            connectToAddress(address, port, timeout);
            connected = true;
        } finally {
            if (!connected) {
                try {
                    close();
                } catch (IOException ioe) {
                    /* Do nothing. If connect threw an exception then
                       it will be passed up the call stack */
                }
            }
        }
    }
602992
protected boolean _connect(long timeout) {
    log.debug("Attempting connection...");
    ConnectFuture connFuture = this.connector.connect(new InetSocketAddress(
        this.host, this.port));
    if (!connFuture.awaitUninterruptibly(timeout)) {
      log.warn("Unable to connect to world model after {}ms.",
          Long.valueOf(this.connectionTimeout));
      return false;
    }
    if (!connFuture.isConnected()) {
      log.debug("Failed to connect.");
      return false;
    }

    try {
      log.debug("Attempting connection to {}:{}.", this.host,
          Integer.valueOf(this.port));
      this.session = connFuture.getSession();
    } catch (RuntimeIoException ioe) {
      log.error(String.format(
          "Could not create session to World Model (C) %s:%d.", this.host,
          Integer.valueOf(this.port)), ioe);
      return false;
    }
    return true;
  }
415450
public MasterWebUIConfiguration setConfiguration(
      TreeSet<Triple<String, String, String>> configuration) {
    mConfiguration = configuration;
    return this;
  }
845037
def _create_connection(self, future):
        
        LOGGER.debug('Creating a new connection for %s', self.pid)

        # Create a new PostgreSQL connection
        kwargs = utils.uri_to_kwargs(self._uri)

        try:
            connection = self._psycopg2_connect(kwargs)
        except (psycopg2.Error, OSError, socket.error) as error:
            future.set_exception(error)
            return

        # Add the connection for use in _poll_connection
        fd = connection.fileno()
        self._connections[fd] = connection

        def on_connected(cf):
            """Invoked by the IOLoop when the future is complete for the
            connection

            :param Future cf: The future for the initial connection

            """
            if cf.exception():
                self._cleanup_fd(fd, True)
                future.set_exception(cf.exception())

            else:

                try:
                    # Add the connection to the pool
                    LOGGER.debug('Connection established for %s', self.pid)
                    self._pool_manager.add(self.pid, connection)
                except (ValueError, pool.PoolException) as err:
                    LOGGER.exception('Failed to add %r to the pool', self.pid)
                    self._cleanup_fd(fd)
                    future.set_exception(err)
                    return

                self._pool_manager.lock(self.pid, connection, self)

                # Added in because psycopg2cffi connects and leaves the
                # connection in a weird state: consts.STATUS_DATESTYLE,
                # returning from Connection._setup without setting the state
                # as const.STATUS_OK
                if utils.PYPY:
                    connection.status = extensions.STATUS_READY

                # Register the custom data types
                self._register_unicode(connection)
                self._register_uuid(connection)

                # Set the future result
                future.set_result(connection)

        # Add a future that fires once connected
        self._futures[fd] = concurrent.Future()
        self._ioloop.add_future(self._futures[fd], on_connected)

        # Add the connection to the IOLoop
        self._ioloop.add_handler(connection.fileno(),
                                 self._on_io_events,
                                 ioloop.IOLoop.WRITE)
311623
def connect(self, connection_config=None, *args, **kwargs):
        
        if self.connected: return self.connected

        if connection_config: self.connection_config = connection_config

        self.connected = True
        try:
            self._connect(self.connection_config)

        except Exception as e:
            self.connected = False
            self.raise_error(e)

        self.log("Connected {}", self.connection_config.interface_name)
        return self.connected
766876
public void configure(String configuration)
        throws IOException
    {

        URL url=Resource.newResource(configuration).getURL();
        if (_configuration!=null && _configuration.equals(url.toString()))
            return;
        if (_configuration!=null)
            throw new IllegalStateException("Already configured with "+_configuration);
        try
        {
            XmlConfiguration config=new XmlConfiguration(url);
            _configuration=url.toString();
            config.configure(this);
        }
        catch(IOException e)
        {
            throw e;
        }
        catch(Exception e)
        {
            log.warn(LogSupport.EXCEPTION,e);
            throw new IOException("Jetty configuration problem: "+e);
        }
    }
1036133
public void addConnection(RedisURI redisURI, CompletableFuture<StatefulRedisConnection<String, String>> connection) {
        connections.put(redisURI, connection);
    }
296779
@Benchmark
	@BenchmarkMode(Mode.AverageTime)
	public void byteArrayFileOutputStream(final Configuration configuration) throws IOException {
		byte[] buffer = new byte[BUFFER_CAPACITY];
		int position = 0;

		try (OutputStream stream = new FileOutputStream(configuration.file)) {
			for (long i = 0; i < LINES; ++i) {
				if (BUFFER_CAPACITY - position < DATA.length) {
					stream.write(buffer, 0, position);
					position = 0;
				}

				if (BUFFER_CAPACITY < DATA.length) {
					stream.write(DATA);
				} else {
					System.arraycopy(DATA, 0, buffer, position, DATA.length);
					position += DATA.length;
				}
			}

			if (position > 0) {
				stream.write(buffer, 0, position);
			}
		}
	}
492875
protected Connection createConnection(Socket socket, InputStream inputStream,
			OutputStream outputStream) throws IOException {
		return new Connection(socket, inputStream, outputStream);
	}
1000926
public static Configuration merge(final Iterable<Configuration> configurations) {
    final ConfigurationBuilder configurationBuilder = Tang.Factory.getTang().newConfigurationBuilder();
    for (final Configuration configuration : configurations) {
      configurationBuilder.addConfiguration(configuration);
    }
    return configurationBuilder.build();
  }
282380
public void connect() {
        doConnect(() -> {
            return CommandContextFactory.getInstance().
                    newCommandContext(new CommandContextConfiguration.Builder()
                    .setErrorOnInteract(false)
                    .build());
        });
    }
867427
@Override
  public Configuration loadConfig() throws ConfigurationException, IOException {

    Configuration resultConfig = new Configuration();

    if (!Utils.localFileExists(this.getConfigFileName())) {
      // String configFileName = System.getenv(ConfigConstant.DDF_INI_ENV_VAR.getValue());
      File file = new File(this.locateConfigFileName(this.getConfigDir(), this.getConfigFileName()));
      mConfigDir = file.getParentFile().getName();
      mConfigFileName = file.getCanonicalPath();
    }

    if (!Utils.localFileExists(this.getConfigFileName())) return null;

    HierarchicalINIConfiguration config = new HierarchicalINIConfiguration(this.getConfigFileName());

    @SuppressWarnings("unchecked")
    Set<String> sectionNames = config.getSections();
    for (String sectionName : sectionNames) {
      SubnodeConfiguration section = config.getSection(sectionName);
      if (section != null) {
        Configuration.Section resultSection = resultConfig.getSection(sectionName);

        @SuppressWarnings("unchecked")
        Iterator<String> keys = section.getKeys();
        while (keys.hasNext()) {
          String key = keys.next();
          String value = section.getString(key);
          if (value != null) {
            resultSection.set(key, value);
          }
        }
      }
    }

    mConfig = resultConfig;
    return mConfig;
  }
564061
public void configure(Configuration configuration){
		setConfiguration(Objects.requireNonNull(configuration));

		setValueFactory(null);

		resetInputFields();
		resetResultFields();
	}