Java Code Examples for org.apache.cassandra.streaming.ProgressInfo

Following code examples demonstrate how to use org.apache.cassandra.streaming.ProgressInfofrom cassandra. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.apache.cassandra.streaming.ProgressInfoand various code implementation of this class.

    }

    public static ProgressInfo fromCompositeData(CompositeData cd)
    {
        Object[] values = cd.getAll(ITEM_NAMES);
        try
        {
            return new ProgressInfo(InetAddress.getByName((String) values[1]),
                                    (int) values[2],
                                    (String) values[3],
                                    ProgressInfo.Direction.valueOf((String)values[4]),
                                    (long) values[5],
                                    (long) values[6]);
        }
        catch (UnknownHostException e)
        {
            throw Throwables.propagate(e);
        }
    } 


    }

    public static CompositeData toCompositeData(UUID planId, ProgressInfo progressInfo)
    {
        Map<String, Object> valueMap = new HashMap<>();
        valueMap.put(ITEM_NAMES[0], planId.toString());
        valueMap.put(ITEM_NAMES[1], progressInfo.peer.getHostAddress());
        valueMap.put(ITEM_NAMES[2], progressInfo.sessionIndex);
        valueMap.put(ITEM_NAMES[3], progressInfo.fileName);
        valueMap.put(ITEM_NAMES[4], progressInfo.direction.name());
        valueMap.put(ITEM_NAMES[5], progressInfo.currentBytes);
        valueMap.put(ITEM_NAMES[6], progressInfo.totalBytes);
        try
        {
            return new CompositeDataSupport(COMPOSITE_TYPE, valueMap);
        }
        catch (OpenDataException e)
        {
            throw Throwables.propagate(e);
        }
    } 

Advertisement
Javadoc
ProgressInfo contains file transfer progress.
Advertisement