Examples of DataOutputStreamAndChannel


Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

                String path = descriptor.filenameFor(Component.FILTER);
                try
                {
                    // bloom filter
                    FileOutputStream fos = new FileOutputStream(path);
                    DataOutputStreamAndChannel stream = new DataOutputStreamAndChannel(fos);
                    FilterFactory.serialize(bf, stream);
                    stream.flush();
                    fos.getFD().sync();
                    stream.close();
                }
                catch (IOException e)
                {
                    throw new FSWriteError(e, path);
                }
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

        Map<MetadataType, MetadataComponent> originalMetadata = collector.finalizeMetadata(partitioner, bfFpChance, 0);

        MetadataSerializer serializer = new MetadataSerializer();
        // Serialize to tmp file
        File statsFile = File.createTempFile(Component.STATS.name, null);
        try (DataOutputStreamAndChannel out = new DataOutputStreamAndChannel(new FileOutputStream(statsFile)))
        {
            serializer.serialize(originalMetadata, out);
        }

        Descriptor desc = new Descriptor( statsFile.getParentFile(), "", "", 0, Descriptor.Type.FINAL);
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

        RangeSliceCommand emptyRangeCmdSup = new RangeSliceCommand(statics.KS, "Super1", statics.readTs, emptyRangePred, bounds, 100);
        MessageOut<RangeSliceCommand> emptyRangeCmdSupMsg = emptyRangeCmdSup.createMessage();
        RangeSliceCommand regRangeCmdSup = new RangeSliceCommand(statics.KS, "Super1", statics.readTs, nonEmptyRangeSCPred, bounds, 100);
        MessageOut<RangeSliceCommand> regRangeCmdSupMsg = regRangeCmdSup.createMessage();

        DataOutputStreamAndChannel out = getOutput("db.RangeSliceCommand.bin");
        namesCmdMsg.serialize(out, getVersion());
        emptyRangeCmdMsg.serialize(out, getVersion());
        regRangeCmdMsg.serialize(out, getVersion());
        namesCmdSupMsg.serialize(out, getVersion());
        emptyRangeCmdSupMsg.serialize(out, getVersion());
        regRangeCmdSupMsg.serialize(out, getVersion());
        out.close();

        // test serializedSize
        testSerializedSize(namesCmd, RangeSliceCommand.serializer);
        testSerializedSize(emptyRangeCmd, RangeSliceCommand.serializer);
        testSerializedSize(regRangeCmd, RangeSliceCommand.serializer);
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

    private void testSliceByNamesReadCommandWrite() throws IOException
    {
        SliceByNamesReadCommand standardCmd = new SliceByNamesReadCommand(statics.KS, statics.Key, statics.StandardCF, statics.readTs, namesPred);
        SliceByNamesReadCommand superCmd = new SliceByNamesReadCommand(statics.KS, statics.Key, statics.SuperCF, statics.readTs, namesSCPred);

        DataOutputStreamAndChannel out = getOutput("db.SliceByNamesReadCommand.bin");
        SliceByNamesReadCommand.serializer.serialize(standardCmd, out, getVersion());
        SliceByNamesReadCommand.serializer.serialize(superCmd, out, getVersion());
        ReadCommand.serializer.serialize(standardCmd, out, getVersion());
        ReadCommand.serializer.serialize(superCmd, out, getVersion());
        standardCmd.createMessage().serialize(out, getVersion());
        superCmd.createMessage().serialize(out, getVersion());
        out.close();

        // test serializedSize
        testSerializedSize(standardCmd, SliceByNamesReadCommand.serializer);
        testSerializedSize(superCmd, SliceByNamesReadCommand.serializer);
    }
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

    private void testSliceFromReadCommandWrite() throws IOException
    {
        SliceFromReadCommand standardCmd = new SliceFromReadCommand(statics.KS, statics.Key, statics.StandardCF, statics.readTs, nonEmptyRangePred);
        SliceFromReadCommand superCmd = new SliceFromReadCommand(statics.KS, statics.Key, statics.SuperCF, statics.readTs, nonEmptyRangeSCPred);
       
        DataOutputStreamAndChannel out = getOutput("db.SliceFromReadCommand.bin");
        SliceFromReadCommand.serializer.serialize(standardCmd, out, getVersion());
        SliceFromReadCommand.serializer.serialize(superCmd, out, getVersion());
        ReadCommand.serializer.serialize(standardCmd, out, getVersion());
        ReadCommand.serializer.serialize(superCmd, out, getVersion());
        standardCmd.createMessage().serialize(out, getVersion());
        superCmd.createMessage().serialize(out, getVersion());

        out.close();

        // test serializedSize
        testSerializedSize(standardCmd, SliceFromReadCommand.serializer);
        testSerializedSize(superCmd, SliceFromReadCommand.serializer);
    }
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

        in.close();
    }

    private void testRowWrite() throws IOException
    {
        DataOutputStreamAndChannel out = getOutput("db.Row.bin");
        Row.serializer.serialize(statics.StandardRow, out, getVersion());
        Row.serializer.serialize(statics.SuperRow, out, getVersion());
        Row.serializer.serialize(statics.NullRow, out, getVersion());
        out.close();

        // test serializedSize
        testSerializedSize(statics.StandardRow, Row.serializer);
        testSerializedSize(statics.SuperRow, Row.serializer);
        testSerializedSize(statics.NullRow, Row.serializer);
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

        Map<UUID, ColumnFamily> mods = new HashMap<UUID, ColumnFamily>();
        mods.put(statics.StandardCf.metadata().cfId, statics.StandardCf);
        mods.put(statics.SuperCf.metadata().cfId, statics.SuperCf);
        Mutation mixedRm = new Mutation(statics.KS, statics.Key, mods);

        DataOutputStreamAndChannel out = getOutput("db.RowMutation.bin");
        Mutation.serializer.serialize(standardRowRm, out, getVersion());
        Mutation.serializer.serialize(superRowRm, out, getVersion());
        Mutation.serializer.serialize(standardRm, out, getVersion());
        Mutation.serializer.serialize(superRm, out, getVersion());
        Mutation.serializer.serialize(mixedRm, out, getVersion());

        standardRowRm.createMessage().serialize(out, getVersion());
        superRowRm.createMessage().serialize(out, getVersion());
        standardRm.createMessage().serialize(out, getVersion());
        superRm.createMessage().serialize(out, getVersion());
        mixedRm.createMessage().serialize(out, getVersion());

        out.close();

        // test serializedSize
        testSerializedSize(standardRowRm, Mutation.serializer);
        testSerializedSize(superRowRm, Mutation.serializer);
        testSerializedSize(standardRm, Mutation.serializer);
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

    private void testTruncateWrite() throws IOException
    {
        Truncation tr = new Truncation(statics.KS, "Doesn't Really Matter");
        TruncateResponse aff = new TruncateResponse(statics.KS, "Doesn't Matter Either", true);
        TruncateResponse neg = new TruncateResponse(statics.KS, "Still Doesn't Matter", false);
        DataOutputStreamAndChannel out = getOutput("db.Truncation.bin");
        Truncation.serializer.serialize(tr, out, getVersion());
        TruncateResponse.serializer.serialize(aff, out, getVersion());
        TruncateResponse.serializer.serialize(neg, out, getVersion());

        tr.createMessage().serialize(out, getVersion());
        aff.createMessage().serialize(out, getVersion());
        neg.createMessage().serialize(out, getVersion());
        // todo: notice how CF names weren't validated.
        out.close();

        // test serializedSize
        testSerializedSize(tr, Truncation.serializer);
        testSerializedSize(aff, TruncateResponse.serializer);
        testSerializedSize(neg, TruncateResponse.serializer);
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

    private void testWriteResponseWrite() throws IOException
    {
        WriteResponse aff = new WriteResponse();
        WriteResponse neg = new WriteResponse();
        DataOutputStreamAndChannel out = getOutput("db.WriteResponse.bin");
        WriteResponse.serializer.serialize(aff, out, getVersion());
        WriteResponse.serializer.serialize(neg, out, getVersion());
        out.close();

        // test serializedSize
        testSerializedSize(aff, WriteResponse.serializer);
        testSerializedSize(neg, WriteResponse.serializer);
    }
View Full Code Here

Examples of org.apache.cassandra.io.util.DataOutputStreamAndChannel

    protected static DataOutputStreamAndChannel getOutput(String name) throws IOException
    {
        File f = new File("test/data/serialization/" + CUR_VER + "/" + name);
        f.getParentFile().mkdirs();
        return new DataOutputStreamAndChannel(new FileOutputStream(f));
    }
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.