Package org.scale7.cassandra.pelops

Examples of org.scale7.cassandra.pelops.Validation


            // iterate through complete map and
            Iterator<Bytes> rowIter = qResults.keySet().iterator();
            while (rowIter.hasNext())
            {
                Bytes rowKey = rowIter.next();

                PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor((Field) metadata
                        .getIdAttribute().getJavaMember());
                Object value = accessor.fromBytes(metadata.getIdAttribute().getJavaType(), rowKey.toByteArray());

                rowKeys.add(value);
            }
        }
        if (rowKeys != null && !rowKeys.isEmpty())
View Full Code Here


        else
        {
            Iterator<Bytes> rowIter = qResults.keySet().iterator();
            while (rowIter.hasNext())
            {
                Bytes rowKey = rowIter.next();
                List<Column> columns = qResults.get(rowKey);
                try
                {
                    Object id = PropertyAccessorHelper
                            .getObject(m.getIdAttribute().getJavaType(), rowKey.toByteArray());
                    Object e = null;
                    e = dataHandler.populateEntity(new ThriftRow(id, m.getTableName(), columns,
                            new ArrayList<SuperColumn>(0), new ArrayList<CounterColumn>(0),
                            new ArrayList<CounterSuperColumn>(0)), m, KunderaCoreUtils.getEntity(e), relationNames,
                            isRelational);
View Full Code Here

                }

                bos.write(COMPONENT_END);
            }

            final Bytes bytes = Bytes.fromByteArray(bos.toByteArray());

            try {
                bos.close();
            } catch (IOException ex) {
                LOGGER.error("Failed to close the compostite type output stream", ex);
View Full Code Here

        builder.addLong(264894651l);
        builder.addShort((short) 1);
        builder.addUTF8("utf8");
        String uuid = UUID.randomUUID().toString();
        builder.addUuid(uuid);
        Bytes bytes = builder.build();

        List<byte[]> parsedBytes = CompositeType.parse(bytes);

        assertNotNull(parsedBytes);
        assertEquals(13, parsedBytes.size());
View Full Code Here

        {
            CassandraHost cassandraHost = (CassandraHost) host;
            String poolName = PelopsUtils.generatePoolName(cassandraHost.getHost(), cassandraHost.getPort(), keyspace);
            if (CassandraUtilities.verifyConnection(cassandraHost.getHost(), cassandraHost.getPort()))
            {
                Cluster cluster = new Cluster(cassandraHost.getHost(), new IConnection.Config(cassandraHost.getPort(),
                        true, -1, PelopsUtils.getAuthenticationRequest(cassandraHost.getUser(),
                                cassandraHost.getPassword())), false);

                if (logger.isInfoEnabled())
                {
View Full Code Here

        if (keyspace == null)
        {
            keyspace = (String) props.get(PersistenceProperties.KUNDERA_KEYSPACE);
        }
        String poolName = PelopsUtils.generatePoolName(cassandraHost.getHost(), cassandraHost.getPort(), keyspace);
        Cluster cluster = new Cluster(cassandraHost.getHost(), new IConnection.Config(cassandraHost.getPort(), true,
                -1, PelopsUtils.getAuthenticationRequest(cassandraHost.getUser(), cassandraHost.getPassword())), false);
        Policy policy = PelopsUtils.getPoolConfigPolicy(cassandraHost);
        try
        {
            Pelops.addPool(poolName, cluster, keyspace, policy, null);
View Full Code Here

     */
    @Test
    public void testInitWithDownedNode() throws Exception {
        final int timeout = 2000;
        final int allowedDeviation = 10; // allowed timeout deviation in percentage
        Cluster cluster = new Cluster(new String[] {RPC_LISTEN_ADDRESS, "192.0.2.0"}, new IConnection.Config(RPC_PORT, true, timeout), false);

        CommonsBackedPool.Policy config = new CommonsBackedPool.Policy();
        config.setTimeBetweenScheduledMaintenanceTaskRunsMillis(-1); // disable the background thread
        config.setMaxActivePerNode(1);

View Full Code Here

    }

    colFamilyDefs = columnDefinitions;

    keyspaceManager = new KeyspaceManager(cluster);
    columnFamilyManager = new ColumnFamilyManager(cluster, KEYSPACE);

    List<KsDef> keyspaces = keyspaceManager.getKeyspaceNames();
    for (KsDef ksDef : keyspaces)
      if (ksDef.name.equals(KEYSPACE)) {
        keyspaceManager.dropKeyspace(KEYSPACE);
View Full Code Here

      Thread.sleep(2000);
    }

    colFamilyDefs = columnDefinitions;

    keyspaceManager = new KeyspaceManager(cluster);
    columnFamilyManager = new ColumnFamilyManager(cluster, KEYSPACE);

    List<KsDef> keyspaces = keyspaceManager.getKeyspaceNames();
    for (KsDef ksDef : keyspaces)
      if (ksDef.name.equals(KEYSPACE)) {
View Full Code Here

     *            A HashMap of field/value pairs to insert in the record
     * @return Zero on success, a non-zero error code on error
     */
    public int insert(String table, String key, HashMap<String, ByteIterator> values)
    {
        Mutator mutator =
                Pelops.createMutator(_host + ":" + _port + ":" + _keyspace);
        try
        {
            List<Column> columns = new ArrayList<Column>();
            for (Map.Entry<String, ByteIterator> entry : values.entrySet())
            {
                Column col = new Column();
                col.setName(ByteBuffer.wrap(entry.getKey().getBytes("UTF-8")));
                col.setValue(ByteBuffer.wrap(entry.getValue().toArray()));
                col.setTimestamp(System.currentTimeMillis());

                columns.add(col);
            }

            mutator.writeColumns(column_family, Bytes.fromUTF8(key), columns);
            mutator.execute(writeConsistencyLevel);

            return Ok;
        }
        catch (Exception e)
        {
View Full Code Here

TOP

Related Classes of org.scale7.cassandra.pelops.Validation

Copyright © 2018 www.massapicom. 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.