cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobrown <...@git.apache.org>
Subject [GitHub] cassandra pull request #204: 14115 v1
Date Thu, 15 Mar 2018 20:04:43 GMT
Github user jasobrown commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/204#discussion_r174135042
  
    --- Diff: src/java/org/apache/cassandra/db/streaming/CassandraStreamManager.java ---
    @@ -0,0 +1,158 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.cassandra.db.streaming;
    +
    +import java.util.ArrayList;
    +import java.util.Collection;
    +import java.util.List;
    +import java.util.Set;
    +import java.util.UUID;
    +
    +import com.google.common.base.Predicate;
    +import com.google.common.base.Predicates;
    +import com.google.common.collect.Iterables;
    +import com.google.common.collect.Sets;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import org.apache.cassandra.db.ColumnFamilyStore;
    +import org.apache.cassandra.db.PartitionPosition;
    +import org.apache.cassandra.db.lifecycle.SSTableIntervalTree;
    +import org.apache.cassandra.db.lifecycle.SSTableSet;
    +import org.apache.cassandra.db.lifecycle.View;
    +import org.apache.cassandra.dht.Range;
    +import org.apache.cassandra.dht.Token;
    +import org.apache.cassandra.io.sstable.format.SSTableReader;
    +import org.apache.cassandra.service.ActiveRepairService;
    +import org.apache.cassandra.streaming.IncomingStream;
    +import org.apache.cassandra.streaming.OutgoingStream;
    +import org.apache.cassandra.streaming.PreviewKind;
    +import org.apache.cassandra.streaming.StreamReceiver;
    +import org.apache.cassandra.streaming.StreamSession;
    +import org.apache.cassandra.streaming.TableStreamManager;
    +import org.apache.cassandra.streaming.messages.StreamMessageHeader;
    +import org.apache.cassandra.utils.Pair;
    +import org.apache.cassandra.utils.concurrent.Ref;
    +import org.apache.cassandra.utils.concurrent.Refs;
    +
    +/**
    + * Implements the streaming interface for the native cassandra storage engine.
    + *
    + * Handles the streaming a one or more section of one of more sstables to and from a
specific
    + * remote node. The sending side performs a block-level transfer of the source stream,
while the receiver
    + * must deserilaize that data stream into an partitions and rows, and then write that
out as an sstable.
    + */
    +public class CassandraStreamManager implements TableStreamManager
    +{
    +    private static final Logger logger = LoggerFactory.getLogger(CassandraStreamManager.class);
    +
    +    private final ColumnFamilyStore cfs;
    +
    +    public CassandraStreamManager(ColumnFamilyStore cfs)
    +    {
    +        this.cfs = cfs;
    +    }
    +
    +    @Override
    +    public IncomingStream prepareIncomingStream(StreamSession session, StreamMessageHeader
header)
    +    {
    +        return new CassandraIncomingFile(cfs, session, header);
    +    }
    +
    +    @Override
    +    public StreamReceiver createStreamReceiver(StreamSession session, int totalStreams)
    +    {
    +        return new CassandraStreamReceiver(cfs, session, totalStreams);
    +    }
    +
    +    private static Predicate<SSTableReader> getPreviewPredicate(PreviewKind kind)
    +    {
    +        switch (kind)
    +        {
    +            case ALL:
    +                return Predicates.alwaysTrue();
    +            case UNREPAIRED:
    +                return Predicates.not(SSTableReader::isRepaired);
    +            case REPAIRED:
    +                return SSTableReader::isRepaired;
    +            default:
    +                throw new IllegalArgumentException("Unsupported kind: " + kind);
    +        }
    +    }
    +
    +    @Override
    +    public Collection<OutgoingStream> createOutgoingStreams(StreamSession session,
Collection<Range<Token>> ranges, UUID pendingRepair, PreviewKind previewKind)
    +    {
    +        Refs<SSTableReader> refs = new Refs<>();
    +        final List<Range<PartitionPosition>> keyRanges = new ArrayList<>(ranges.size());
    --- End diff --
    
    `StreamSession.getSSTableSectionsForRanges` included a `try` after that encompassed most
of the function, and would release the `refs` on any failure. Was that unnecessary, or should
we keep it? 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message