Package org.apache.cassandra.db

Examples of org.apache.cassandra.db.RowMutation


      // TODO : handle deletes
      Row diffRow = rowList.get(i).diff(retRow);
      if(diffRow == null) // no repair needs to happen
        continue;
      // create the row mutation message based on the diff and schedule a read repair
      RowMutation rowMutation = new RowMutation(table, key);                 
        Map<String, ColumnFamily> columnFamilies = diffRow.getColumnFamilyMap();
          Set<String> cfNames = columnFamilies.keySet();
         
          for ( String cfName : cfNames )
          {
              ColumnFamily cf = columnFamilies.get(cfName);
              rowMutation.add(cf);
          }
            RowMutationMessage rowMutationMessage = new RowMutationMessage(rowMutation);
          // schedule the read repair
          ReadRepairManager.instance().schedule(endPoints.get(i),rowMutationMessage);
    }
View Full Code Here


      while(true)
      {
        int key = random.nextInt(keys) + 1;
              String stringKey = new Integer(key).toString();
              stringKey = stringKey + keyFix_ ;
              RowMutation rm = new RowMutation(tablename_, stringKey);
              int j = random.nextInt(columns) + 1;
                random.nextBytes(bytes);
                rm.add( columnFamilyColumn_ + ":" + columnFix_ + j, bytes, ts);
                if ( ts == Integer.MAX_VALUE)
                {
                  ts = 0 ;
                }
                ts++;
View Full Code Here

      while(true)
      {
        int key = random.nextInt(keys) + 1;
              String stringKey = new Integer(key).toString();
              stringKey = stringKey + keyFix_ ;
              RowMutation rm = new RowMutation(tablename_, stringKey);
              int i = random.nextInt(superColumns) + 1;
              int j = random.nextInt(columns) + 1;
                random.nextBytes(bytes);
                rm.add( columnFamilySuperColumn_ + ":" + superColumnFix_ + i + ":" + columnFix_ + j, bytes, ts);
                if ( ts == Integer.MAX_VALUE )
                {
                  ts = 0 ;
                }
                ts++;
View Full Code Here

    {
      for(int key = 1; key <= keys ; key++)
      {
              String stringKey = new Integer(key).toString();
              stringKey = stringKey + keyFix_ ;
              RowMutation rm = new RowMutation(tablename_, stringKey);
              for( int j = 1; j <= columns ; j++)
              {
                  random.nextBytes(bytes);
                  rm.add( columnFamilyColumn_ + ":" + columnFix_ + j, bytes, ts);
              }
        RowMutationMessage rmMsg = new RowMutationMessage(rm);
       
        for(int k = 0 ; k < requestsPerSecond_/1000 +1 ; k++ )
        {
View Full Code Here

    {
      for(int key = 1; key <= keys ; key++)
      {
              String stringKey = new Integer(key).toString();
              stringKey = stringKey + keyFix_ ;
              RowMutation rm = new RowMutation(tablename_, stringKey);
              for( int i = 1; i <= superColumns ; i++)
              {
                for( int j = 1; j <= columns ; j++)
                {
                    random.nextBytes(bytes);
                    rm.add( columnFamilySuperColumn_ + ":" + superColumnFix_ + i + ":" + columnFix_ + j, bytes, ts);
                }
              }
              RowMutationMessage rmMsg = new RowMutationMessage(rm);
        for(int k = 0 ; k < requestsPerSecond_/1000 +1 ; k++ )
        {
View Full Code Here

  }

  public void run(int operation, String columnFamilyName, long skip) throws Throwable
  {
        byte[] bytes =  BasicUtilities.longToByteArray( skip );
        RowMutation rm = new RowMutation(tableName_, key_);
        if( columnFamilyName == null )
        {
      rm.add(Table.recycleBin_ + ":" + cf1_, bytes, operation);
      rm.add(Table.recycleBin_ + ":" + cf2_, bytes, operation);
      rm.add(Table.recycleBin_ + ":" + cf3_, bytes, operation);
      rm.add(Table.recycleBin_ + ":" + cf4_, bytes, operation);
//      rm.add(Table.recycleBin_ + ":" + cf5_, bytes, operation);
        }
        else
        {
      rm.add(Table.recycleBin_ + ":" + columnFamilyName, bytes, operation);
        }
    RowMutationMessage rmMsg = new RowMutationMessage(rm);
        if( server_ != null)
        {
            Message message = RowMutationMessage.makeRowMutationMessage(rmMsg, StorageService.binaryVerbHandler_);
View Full Code Here

    public static Message createMessage(String keyspace, byte[] key, String columnFamily, List<ColumnFamily> columnFamilies)
    {
        ColumnFamily baseColumnFamily;
        DataOutputBuffer bufOut = new DataOutputBuffer();
        RowMutation rm;
        Message message;
        Column column;

        /* Get the first column family from list, this is just to get past validation */
        baseColumnFamily = new ColumnFamily(ColumnFamilyType.Standard,
                                            DatabaseDescriptor.getComparator(keyspace, columnFamily),
                                            DatabaseDescriptor.getSubComparator(keyspace, columnFamily),
                                            CFMetaData.getId(keyspace, columnFamily));
       
        for(ColumnFamily cf : columnFamilies) {
            bufOut.reset();
            ColumnFamily.serializer().serializeWithIndexes(cf, bufOut);
            byte[] data = new byte[bufOut.getLength()];
            System.arraycopy(bufOut.getData(), 0, data, 0, bufOut.getLength());

            column = new Column(FBUtilities.toByteBuffer(cf.id()), ByteBuffer.wrap(data), 0);
            baseColumnFamily.addColumn(column);
        }
        rm = new RowMutation(keyspace, ByteBuffer.wrap(key));
        rm.add(baseColumnFamily);

        try
        {
            /* Make message */
            message = rm.makeRowMutationMessage(StorageService.Verb.BINARY);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

                    // but just in case there is no harm in trying them.
                    continue;
                }

                /* deserialize the commit log entry */
                final RowMutation rm = RowMutation.serializer().deserialize(new DataInputStream(bufIn));
                if (logger.isDebugEnabled())
                    logger.debug(String.format("replaying mutation for %s.%s: %s",
                                                rm.getTable(),
                                                rm.key(),
                                                "{" + StringUtils.join(rm.getColumnFamilies(), ", ") + "}"));
                final Table table = Table.open(rm.getTable());
                tablesRecovered.add(table);
                final Collection<ColumnFamily> columnFamilies = new ArrayList<ColumnFamily>(rm.getColumnFamilies());
                final long entryLocation = reader.getFilePointer();
                Runnable runnable = new WrappedRunnable()
                {
                    public void runMayThrow() throws IOException
                    {
                        /* remove column families that have already been flushed before applying the rest */
                        for (ColumnFamily columnFamily : columnFamilies)
                        {
                            int id = table.getColumnFamilyId(columnFamily.name());
                            if (!clHeader.isDirty(id) || entryLocation < clHeader.getPosition(id))
                            {
                                rm.removeColumnFamily(columnFamily);
                            }
                        }
                        if (!rm.isEmpty())
                        {
                            Table.open(rm.getTable()).apply(rm, null, false);
                        }
                    }
                };
                futures.add(StageManager.getStage(StageManager.MUTATION_STAGE).submit(runnable));
                if (futures.size() > MAX_OUTSTANDING_REPLAY_COUNT)
View Full Code Here

    private static SSTableReader makeSSTable()
    {
        Table t = Table.open("Keyspace1");
        for (int i = 0; i < 100; i++)
        {
            RowMutation rm = new RowMutation(t.name, ByteBufferUtil.bytes(Long.toString(System.nanoTime())));
            rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("cola")), ByteBufferUtil.bytes("value"), 0);
            try
            {
                rm.apply();
            }
            catch (IOException ex)
            {
                throw new RuntimeException(ex);
            }
View Full Code Here

                if (expiredCallbackInfo.shouldHint())
                {
                    assert expiredCallbackInfo.message != null;
                    try
                    {
                        RowMutation rm = RowMutation.fromBytes(expiredCallbackInfo.message.getMessageBody(), expiredCallbackInfo.message.getVersion());
                        return StorageProxy.scheduleLocalHint(rm, expiredCallbackInfo.target, null, null);
                    }
                    catch (IOException e)
                    {
                        logger_.error("Unable to deserialize mutation when writting hint for: " + expiredCallbackInfo.target);
View Full Code Here

TOP

Related Classes of org.apache.cassandra.db.RowMutation

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.