Examples of ConnectionManager


Examples of com.google.code.http4j.ConnectionManager

  }

  @Test(expectedExceptions = TimeoutException.class)
  public void setMaxConnectionsPerHost() throws InterruptedException,
      ExecutionException, TimeoutException, IOException {
    final ConnectionManager pool = new ConnectionPool();
    pool.setMaxConnectionsPerHost(1);
    try {
      Connection connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      pool.release(connection);
      connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      ExecutorService service = Executors.newSingleThreadExecutor();
      service.invokeAny(Collections.singleton(new Callable<Connection>() {
        @Override
        public Connection call() throws Exception {
          return pool.acquire(host);
        }
      }), 2, TimeUnit.SECONDS);
    } finally {
      pool.shutdown();
    }
  }
View Full Code Here

Examples of com.hazelcast.nio.ConnectionManager

        } else if (uri.startsWith(URI_CLUSTER)) {
            Node node = textCommandService.getNode();
            StringBuilder res = new StringBuilder(node.getClusterService().membersString());
            res.append("\n");
            ConnectionManager connectionManager = node.getConnectionManager();
            res.append("ConnectionCount: ").append(connectionManager.getCurrentClientConnections());
            res.append("\n");
            res.append("AllConnectionCount: ").append(connectionManager.getAllTextConnections());
            res.append("\n");
            command.setResponse(null, stringToBytes(res.toString()));
        } else if (uri.startsWith(URI_STATE_DUMP)) {
            String stateDump = textCommandService.getNode().getSystemLogService().dump();
            stateDump += textCommandService.getNode().getPartitionService().toString() + "\n";
View Full Code Here

Examples of com.hazelcast.nio.ConnectionManager

    public boolean send(Packet packet, Address target) {
        return send(packet, target, null);
    }

    private boolean send(Packet packet, Address target, FutureSend futureSend) {
        final ConnectionManager connectionManager = node.getConnectionManager();
        final Connection connection = connectionManager.getConnection(target);
        if (connection != null) {
            return send(packet, connection);
        } else {
            if (futureSend == null) {
                futureSend = new FutureSend(packet, target);
            }
            final int retries = futureSend.retries;
            if (retries < 5 && node.isActive()) {
                connectionManager.getOrConnect(target, true);
                // TODO: Caution: may break the order guarantee of the packets sent from the same thread!
                executionService.schedule(futureSend, (retries + 1) * 100, TimeUnit.MILLISECONDS);
                return true;
            }
            return false;
View Full Code Here

Examples of com.jengine.orm.db.adapter.ConnectionManager

import static com.jengine.utils.commons.CollectionUtil.map;

public class Test {

    public static void main(String [] args) throws Exception {
        ConnectionManager connectionManager = new DBCPConnectionPool(newDBCPDataSource());
//        ConnectionManager connectionManager = new SingleConnectionManager("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/bookdb?", "root", "");
        Adapter adapter = new JDBCAdapter(connectionManager);
        EhcacheManager cacheManager = new EhcacheManager(newEhcacheManager());
        Provider provider = new MySQLProvider(adapter, cacheManager);
        DB db = DBFactory.register(new DB(provider));
View Full Code Here

Examples of com.pardot.rhombus.ConnectionManager

        System.setProperty("cassandra.config", "cassandra-config/cassandra.yaml");
        String defaultTableName = "simple";
        String testUniqueTableName = "simpleA";

        //Build the connection manager
        ConnectionManager cm = getConnectionManager();

        //Build our keyspace definition object
        CKeyspaceDefinition keyspaceDefinition = JsonUtil.objectFromJsonResource(CKeyspaceDefinition.class, this.getClass().getClassLoader(), "TableWriterSimpleKeyspace.js");
        assertNotNull(keyspaceDefinition);
        String keyspaceName = keyspaceDefinition.getName();
        // Hardcode this for simplicity
        ShardingStrategyMonthly shardStrategy = new ShardingStrategyMonthly();

        // SSTableWriter craps out if we try to close a writer on a table and then create a new one on the same table, so each test should write to different tables
        Map<String, CDefinition> tableDefs = keyspaceDefinition.getDefinitions();
        CDefinition def = tableDefs.get(defaultTableName);
        def.setName(testUniqueTableName);
        tableDefs.remove(defaultTableName);
        tableDefs.put(testUniqueTableName, def);

        // Make sure the SSTableOutput directory exists and is clear
        File keyspaceDir = new File(keyspaceName);
        if (keyspaceDir.exists()) {
            FileUtils.deleteRecursive(new File(keyspaceName));
        }
        assertTrue(new File(keyspaceName).mkdir());

        //Rebuild the keyspace and get the object mapper
        cm.buildKeyspace(keyspaceDefinition, true);
        logger.debug("Built keyspace: {}", keyspaceDefinition.getName());
        cm.setDefaultKeyspace(keyspaceDefinition);
        ObjectMapper om = cm.getObjectMapper();
        om.setLogCql(true);
        om.truncateTables();

        // This is the only static table definition this test keyspace has
        List<String> staticTableNames = Arrays.asList(testUniqueTableName);

        //Insert our test data into the SSTable
        // For this test, all this data goes into the one table we have defined
        List<Map<String, Object>> values = JsonUtil.rhombusMapFromResource(this.getClass().getClassLoader(), "SSTableWriterSimpleTestData.js");
        // Tack on time based UUIDs because we don't really care what the UUID values are
        for (Map<String, Object> map : values) {
            map.put("id", UUIDs.startOf(Long.parseLong(map.get("created_at").toString(), 10)));
        }
        // Build the map to insert that we'll actually pass in
        Map<String, List<Map<String, Object>>> insert = new HashMap<String, List<Map<String, Object>>>();
        for (String staticTableName : staticTableNames) {
            insert.put(staticTableName, values);
        }

        // Actually insert the data into the SSTableWriters
        om.initializeSSTableWriters(false);
        om.insertIntoSSTable(insert);
        om.completeSSTableWrites();

        // Figure out all the table names (including index tables) so we can load them into Cassandra
        File[] tableDirs = keyspaceDir.listFiles();
        assertNotNull(tableDirs);
        List<String> allTableNames = Lists.newArrayList();
        for (File file : tableDirs) {
            if (file != null) {
                allTableNames.add(file.getName());
            }
        }
        for (String tableName : allTableNames) {
            String SSTablePath = keyspaceName + "/" + tableName;

            // Load the SSTables into Cassandra
            ProcessBuilder builder = new ProcessBuilder("sstableloader", "-d", "localhost", SSTablePath);
            builder.redirectErrorStream(true);
            Process p = builder.start();
            BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
            long startTime = System.currentTimeMillis();
            // TODO: sleep is the devil
            while (!r.readLine().contains("100%") && ((System.currentTimeMillis() - startTime) < 10000)) {
                Thread.sleep(100);
            }
        }

        String staticTableName = staticTableNames.get(0);
        for (Map<String, Object> expected : values) {
            Map<String, Object> actual = om.getByKey(staticTableName, expected.get("id"));
            assertEquals(expected, actual);
        }

        Map<String, Map<String, Object>> indexedExpected = Maps.uniqueIndex(values, new Function<Map<String, Object>,String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
            }});
        // Confirm get by index_1 query
        SortedMap<String, Object> indexValues = Maps.newTreeMap();
        indexValues.put("index_1", "index1");
        Criteria criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        List<Map<String, Object>> results = om.list(testUniqueTableName, criteria);
        Map<String, Map<String, Object>> indexedResults;
        indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>, String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
            }
        });
        Map<String, Map<String, Object>> indexedExpected1 = Maps.newHashMap(indexedExpected);
        // Index_1 test data doesn't include value 4
        indexedExpected1.remove("864f1400-2a7e-11b2-8080-808080808080");
        assertEquals(indexedExpected1, indexedResults);

        // Confirm get by index_2 query
        indexValues = Maps.newTreeMap();
        indexValues.put("index_2", "index2");
        criteria = new Criteria();
        criteria.setIndexKeys(indexValues);
        criteria.setLimit(50L);
        results = om.list(testUniqueTableName, criteria);

        indexedResults = Maps.uniqueIndex(results, new Function<Map<String, Object>,String>() {
            public String apply(Map<String, Object> input) {
                return input.get("id").toString();
            }});

        Map<String, Map<String, Object>> indexedExpected2 = Maps.newHashMap(indexedExpected);
        // Index_2 test data doesn't include value 3
        indexedExpected2.remove("80593300-2a7e-11b2-8080-808080808080");
        assertEquals(indexedExpected2, indexedResults);

        // Clean up the SSTable directories after ourselves
        FileUtils.deleteRecursive(new File(keyspaceName));

    cm.teardown();
    }
View Full Code Here

Examples of com.redhat.gss.redhat_support_lib.web.ConnectionManager

   */
  public API(String username, String password, String url, String proxyUser,
      String proxyPassword, URL proxyUrl, int proxyPort, String userAgent) {
    config = new ConfigHelper(username, password, url, proxyUser,
        proxyPassword, proxyUrl, proxyPort, userAgent, false);
    connectionManager = new ConnectionManager(config);

    solutions = new Solutions(connectionManager);
    articles = new Articles(connectionManager);
    cases = new Cases(connectionManager);
    products = new Products(connectionManager);
View Full Code Here

Examples of com.sun.enterprise.ee.admin.lbadmin.connection.ConnectionManager

            String lbPort = port!=null?port.getValue():null;
            String lbProxyHost = proxyHost!=null?proxyHost.getValue():null;
            String lbProxyPort = proxyPort!=null?proxyPort.getValue():null;
            boolean isSec = secProp!=null? Boolean.getBoolean(secProp.getValue()):true;

            _connectionManager = new
            ConnectionManager(lbHost,lbPort,lbProxyHost,lbProxyPort,lbName,isSec);
        } catch ( Exception e ){
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of com.sun.jdo.spi.persistence.support.sqlstore.connection.ConnectionManager

      assertConnectionWait();

                // need to use this constructor, as it calls internaly startUp() method
                // to initialize extra variables and enable pooling
      //java.sql.DriverManager.setLogWriter(logWriter);
                   connectionManager = new ConnectionManager(
                            driverName,
                            URL,
                            userName,
                            password,
                            minPool,
View Full Code Here

Examples of com.sun.messaging.jmq.jmsserver.service.ConnectionManager

                ServiceManager sm = Globals.getServiceManager();

                // OK .. first stop sending anything out
                sm.stopNewConnections(ServiceType.ADMIN);

                ConnectionManager cmgr = Globals.getConnectionManager();

                Globals.getLogger().logToAll(Logger.INFO,
                                         BrokerResources.I_BROADCAST_GOODBYE);
                int id = GoodbyeReason.SHUTDOWN_BKR;
                String msg =
                    Globals.getBrokerResources().getKString(
                         BrokerResources.M_ADMIN_REQ_SHUTDOWN,
                          requestedBy);

                if (exitCode == getRestartCode()) {
                    id = GoodbyeReason.RESTART_BKR;
                    msg = Globals.getBrokerResources().getKString(
                             BrokerResources.M_ADMIN_REQ_RESTART,
                              requestedBy);
                }
                cmgr.broadcastGoodbye(id, msg);

                Globals.getLogger().logToAll(Logger.INFO,
                                         BrokerResources.I_FLUSH_GOODBYE);
                cmgr.flushControlMessages(1000);
   
                // XXX - should be notify other brokers we are going down ?

                sm.stopAllActiveServices(true);
View Full Code Here

Examples of connection.ConnectionManager

  public static void main(String[] args)
  {
    fileManager = new FileManager();
    searchManager = new QueryManager();

    connectionManager = new ConnectionManager();

    networkManager = new NetworkManager();

    System.out.println("Sillian server started");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.