Examples of Keyspace


Examples of me.prettyprint.hector.api.Keyspace

public class MainProg {

  public static void main(String[] args) {
    Cluster cluster = HFactory.getOrCreateCluster("TestPool", "localhost:9160");
    Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);

    EntityManagerImpl em = new EntityManagerImpl(keyspace, "com.mycompany");

    MyPojo pojo1 = new MyPojo();
    pojo1.setId(UUID.randomUUID());
View Full Code Here

Examples of me.prettyprint.hector.api.Keyspace

                                                      SimpleStrategy.class.getName(), 1, Arrays.asList(cfDef));

            cassandraCluster.addKeyspace(keyspaceDefinition);
        }

        Keyspace friendListKS = HFactory.createKeyspace(Constants.KEYSPACE_NAME, cassandraCluster);
        //cassandraCluster.getConnectionManager().shutdown(); // shutdown the connection 
        return friendListKS;
    }
View Full Code Here

Examples of me.prettyprint.hector.api.Keyspace

    private String getFriendsList(String id) {
        /*Cluster cassandraCluster = HFactory.createCluster(
                Constants.CLUSTER_NAME, new CassandraHostConfigurator(Constants.CLUSTER_HOST), credentials);*/
        System.out.println("#######   In getFriendsList()   #######");
        //Keyspace keyspaceOperator = HFactory.createKeyspace(Constants.KEYSPACE_NAME, cassandraCluster);
        Keyspace keyspaceOperator = getKeyspace();
        // query to get the list of friends for a particular user id
        SliceQuery<String, Long, String> query = HFactory.createSliceQuery(keyspaceOperator, ss, ls, ss).
                setColumnFamily(Constants.COL_FAMILY_NAME).setKey(id).setRange(0L, Long.MAX_VALUE, false, 4);
        QueryResult<ColumnSlice<Long, String>> result = query.execute();
        ColumnSlice<Long, String> resultCols = result.get();
View Full Code Here

Examples of me.prettyprint.hector.api.Keyspace

public class ReadColumn {

    public static void main(String arg[]) {

        Cluster cluster = ExampleHelper.createCluster("test", "test123");
        Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);
        ColumnQuery<String, String, String> columnQuery =
                HFactory.createStringColumnQuery(keyspace);
        columnQuery.setColumnFamily("CFone").setKey("keyone").setName("name");
        QueryResult<HColumn<String, String>> result = columnQuery.execute();
        HColumn<String, String> hColumn = result.get();
View Full Code Here

Examples of me.prettyprint.hector.api.Keyspace

     * Create a keyspace, add a column family and read a column's value
     */
    private static void createKeyspace() {
        KeyspaceDefinition definition = new ThriftKsDef("TestKeyspace");
        cluster.addKeyspace(definition);
        Keyspace keyspace = HFactory.createKeyspace("TestKeyspace", cluster);
        ColumnFamilyDefinition familyDefinition = new ThriftCfDef("TestKeyspace", "CFone");
        cluster.addColumnFamily(familyDefinition);
        Mutator<String> mutator = HFactory.createMutator(keyspace, new StringSerializer());
        mutator.insert("keyone", "CFone", HFactory.createStringColumn("name", "C Ronaldo"));
        ColumnQuery<String, String, String> columnQuery =
View Full Code Here

Examples of org.apache.cassandra.db.Keyspace

        return false;
    }

    private static void commitPaxos(Commit proposal, ConsistencyLevel consistencyLevel) throws WriteTimeoutException
    {
        Keyspace keyspace = Keyspace.open(proposal.update.metadata().ksName);

        Token tk = StorageService.getPartitioner().getToken(proposal.key);
        List<InetAddress> naturalEndpoints = StorageService.instance.getNaturalEndpoints(keyspace.getName(), tk);
        Collection<InetAddress> pendingEndpoints = StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, keyspace.getName());

        AbstractReplicationStrategy rs = keyspace.getReplicationStrategy();
        AbstractWriteResponseHandler responseHandler = rs.getWriteResponseHandler(naturalEndpoints, pendingEndpoints, consistencyLevel, null, WriteType.SIMPLE);

        MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_COMMIT, proposal, Commit.serializer);
        for (InetAddress destination : Iterables.concat(naturalEndpoints, pendingEndpoints))
        {
View Full Code Here

Examples of org.apache.cassandra.db.Keyspace

     * is unclear we want to mix those latencies with read latencies, so this
     * may be a bit involved.
     */
    private static InetAddress findSuitableEndpoint(String keyspaceName, ByteBuffer key, String localDataCenter, ConsistencyLevel cl) throws UnavailableException
    {
        Keyspace keyspace = Keyspace.open(keyspaceName);
        IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
        List<InetAddress> endpoints = StorageService.instance.getLiveNaturalEndpoints(keyspace, key);
        if (endpoints.isEmpty())
            // TODO have a way to compute the consistency level
            throw new UnavailableException(cl, cl.blockFor(keyspace), 0);
View Full Code Here

Examples of org.apache.cassandra.db.Keyspace

    throws UnavailableException, ReadTimeoutException
    {
        Tracing.trace("Computing ranges to query");
        long startTime = System.nanoTime();

        Keyspace keyspace = Keyspace.open(command.keyspace);
        List<Row> rows;
        // now scan until we have enough results
        try
        {
            int cql3RowCount = 0;
            rows = new ArrayList<>();

            // when dealing with LocalStrategy keyspaces, we can skip the range splitting and merging (which can be
            // expensive in clusters with vnodes)
            List<? extends AbstractBounds<RowPosition>> ranges;
            if (keyspace.getReplicationStrategy() instanceof LocalStrategy)
                ranges = command.keyRange.unwrap();
            else
                ranges = getRestrictedRanges(command.keyRange);

            // our estimate of how many result rows there will be per-range
View Full Code Here

Examples of org.apache.cassandra.db.Keyspace

            this.handler = handler;
        }

        protected void runMayThrow()
        {
            Keyspace keyspace = Keyspace.open(command.ksName);
            Row r = command.getRow(keyspace);
            ReadResponse result = ReadVerbHandler.getResponse(command, r);
            MessagingService.instance().addLatency(FBUtilities.getBroadcastAddress(), TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
            handler.response(result);
        }
View Full Code Here

Examples of org.apache.cassandra.db.Keyspace

        return false;
    }

    private static void commitPaxos(Commit proposal, ConsistencyLevel consistencyLevel) throws WriteTimeoutException
    {
        Keyspace keyspace = Keyspace.open(proposal.update.metadata().ksName);

        Token tk = StorageService.getPartitioner().getToken(proposal.key);
        List<InetAddress> naturalEndpoints = StorageService.instance.getNaturalEndpoints(keyspace.getName(), tk);
        Collection<InetAddress> pendingEndpoints = StorageService.instance.getTokenMetadata().pendingEndpointsFor(tk, keyspace.getName());

        AbstractReplicationStrategy rs = keyspace.getReplicationStrategy();
        AbstractWriteResponseHandler responseHandler = rs.getWriteResponseHandler(naturalEndpoints, pendingEndpoints, consistencyLevel, null, WriteType.SIMPLE);

        MessageOut<Commit> message = new MessageOut<Commit>(MessagingService.Verb.PAXOS_COMMIT, proposal, Commit.serializer);
        for (InetAddress destination : Iterables.concat(naturalEndpoints, pendingEndpoints))
        {
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.