Java Code Examples for org.apache.cassandra.net.MessagingService#VERSION_20

The following examples show how to use org.apache.cassandra.net.MessagingService#VERSION_20 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColumnFamilySerializer.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public ColumnFamily deserialize(DataInput in, ColumnFamily.Factory factory, ColumnSerializer.Flag flag, int version) throws IOException
{
    if (!in.readBoolean())
        return null;

    ColumnFamily cf = factory.create(Schema.instance.getCFMetaData(deserializeCfId(in, version)));

    if (cf.metadata().isSuper() && version < MessagingService.VERSION_20)
    {
        SuperColumns.deserializerSuperColumnFamily(in, cf, flag, version);
    }
    else
    {
        cf.delete(cf.getComparator().deletionInfoSerializer().deserialize(in, version));

        ColumnSerializer columnSerializer = cf.getComparator().columnSerializer();
        int size = in.readInt();
        for (int i = 0; i < size; ++i)
            cf.addColumn(columnSerializer.deserialize(in, flag));
    }
    return cf;
}
 
Example 2
Source File: Mutation.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public long serializedSize(Mutation mutation, int version)
{
    TypeSizes sizes = TypeSizes.NATIVE;
    int size = 0;

    if (version < MessagingService.VERSION_20)
        size += sizes.sizeof(mutation.getKeyspaceName());

    int keySize = mutation.key().remaining();
    size += sizes.sizeof((short) keySize) + keySize;

    size += sizes.sizeof(mutation.modifications.size());
    for (Map.Entry<UUID,ColumnFamily> entry : mutation.modifications.entrySet())
        size += ColumnFamily.serializer.serializedSize(entry.getValue(), TypeSizes.NATIVE, version);

    return size;
}
 
Example 3
Source File: StorageConnection.java    From sstable-tools with Apache License 2.0 5 votes vote down vote up
public synchronized void enqueue(MessageOut<?> message, int id) throws IOException {
    long timestamp = System.currentTimeMillis();
    out.writeInt(MessagingService.PROTOCOL_MAGIC);

    if (targetVersion < MessagingService.VERSION_20)
        out.writeUTF(String.valueOf(id));
    else
        out.writeInt(id);
    out.writeInt((int) timestamp);
    message.serialize(out, targetVersion);
    out.flush();
}
 
Example 4
Source File: Gossiper.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private void markAlive(final InetAddress addr, final EndpointState localState)
{
    if (MessagingService.instance().getVersion(addr) < MessagingService.VERSION_20)
    {
        realMarkAlive(addr, localState);
        return;
    }

    localState.markDead();

    MessageOut<EchoMessage> echoMessage = new MessageOut<EchoMessage>(MessagingService.Verb.ECHO, new EchoMessage(), EchoMessage.serializer);
    logger.trace("Sending a EchoMessage to {}", addr);
    IAsyncCallback echoHandler = new IAsyncCallback()
    {
        public boolean isLatencyForSnitch()
        {
            return false;
        }

        public void response(MessageIn msg)
        {
            realMarkAlive(addr, localState);
        }
    };

    MessagingService.instance().sendRR(echoMessage, addr, echoHandler);
}
 
Example 5
Source File: CommitLogDescriptor.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public int getMessagingVersion()
{
    switch (version)
    {
        case VERSION_12:
            return MessagingService.VERSION_12;
        case VERSION_20:
            return MessagingService.VERSION_20;
        case VERSION_21:
            return MessagingService.VERSION_21;
        default:
            throw new IllegalStateException("Unknown commitlog version " + version);
    }
}
 
Example 6
Source File: RangeTombstoneList.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public RangeTombstoneList deserialize(DataInput in, int version) throws IOException
{
    int size = in.readInt();
    if (size == 0)
        return null;

    RangeTombstoneList tombstones = new RangeTombstoneList(type, size);

    for (int i = 0; i < size; i++)
    {
        Composite start = type.serializer().deserialize(in);
        Composite end = type.serializer().deserialize(in);
        int delTime =  in.readInt();
        long markedAt = in.readLong();

        if (version >= MessagingService.VERSION_20)
        {
            tombstones.setInternal(i, start, end, markedAt, delTime);
        }
        else
        {
            /*
             * The old implementation used to have range sorted by left value, but with potentially
             * overlapping range. So we need to use the "slow" path.
             */
            tombstones.add(start, end, markedAt, delTime);
        }
    }

    // The "slow" path take care of updating the size, but not the fast one
    if (version >= MessagingService.VERSION_20)
        tombstones.size = size;
    return tombstones;
}