You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2020/10/08 00:08:17 UTC

[cassandra] branch cassandra-3.0 updated (8d2556f -> 5ef77d2)

This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a change to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from 8d2556f  Merge branch 'cassandra-2.2' into cassandra-3.0
     new 0eb8cec  Backport changes from CASSANDRA-16120 to other branches
     new 5ef77d2  Merge branch 'cassandra-2.2' into cassandra-3.0

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 test/conf/logback-dtest.xml                        |  27 +----
 .../distributed/impl/AbstractCluster.java          |  22 +++-
 ...nstanceIDDefiner.java => ClusterIDDefiner.java} |  22 ++--
 .../cassandra/distributed/impl/FileLogAction.java  | 133 +++++++++++++++++++++
 .../cassandra/distributed/impl/Instance.java       |  24 +++-
 .../distributed/impl/InstanceIDDefiner.java        |  12 +-
 .../cassandra/distributed/test/JVMDTestTest.java   |  28 +++++
 7 files changed, 229 insertions(+), 39 deletions(-)
 copy test/distributed/org/apache/cassandra/distributed/impl/{InstanceIDDefiner.java => ClusterIDDefiner.java} (72%)
 create mode 100644 test/distributed/org/apache/cassandra/distributed/impl/FileLogAction.java


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


[cassandra] 01/01: Merge branch 'cassandra-2.2' into cassandra-3.0

Posted by dc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 5ef77d234f26e985811db4ff5fc2f01f6fe5a29c
Merge: 8d2556f 0eb8cec
Author: David Capwell <dc...@apache.org>
AuthorDate: Wed Oct 7 17:03:07 2020 -0700

    Merge branch 'cassandra-2.2' into cassandra-3.0

 test/conf/logback-dtest.xml                        |  27 +----
 .../distributed/impl/AbstractCluster.java          |  22 +++-
 ...nstanceIDDefiner.java => ClusterIDDefiner.java} |  22 ++--
 .../cassandra/distributed/impl/FileLogAction.java  | 133 +++++++++++++++++++++
 .../cassandra/distributed/impl/Instance.java       |  24 +++-
 .../distributed/impl/InstanceIDDefiner.java        |  12 +-
 .../cassandra/distributed/test/JVMDTestTest.java   |  28 +++++
 7 files changed, 229 insertions(+), 39 deletions(-)

diff --cc test/distributed/org/apache/cassandra/distributed/impl/FileLogAction.java
index 0000000,1d65fe1..0f48a23
mode 000000,100644..100644
--- a/test/distributed/org/apache/cassandra/distributed/impl/FileLogAction.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/FileLogAction.java
@@@ -1,0 -1,133 +1,133 @@@
+ /*
+  * 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.distributed.impl;
+ 
+ import java.io.File;
+ import java.io.FileNotFoundException;
+ import java.io.IOException;
+ import java.io.RandomAccessFile;
+ import java.io.UncheckedIOException;
+ import java.util.Objects;
+ import java.util.function.Predicate;
+ 
 -import com.google.common.collect.AbstractIterator;
+ import com.google.common.io.Closeables;
+ 
++import org.apache.cassandra.utils.AbstractIterator;
+ import org.apache.cassandra.distributed.api.LogAction;
+ import org.apache.cassandra.distributed.api.LineIterator;
+ 
+ public class FileLogAction implements LogAction
+ {
+     private final File file;
+ 
+     public FileLogAction(File file)
+     {
+         this.file = Objects.requireNonNull(file);
+     }
+ 
+     @Override
+     public long mark()
+     {
+         return file.length();
+     }
+ 
+     @Override
+     public LineIterator match(long startPosition, Predicate<String> fn)
+     {
+         RandomAccessFile reader;
+         try
+         {
+             reader = new RandomAccessFile(file, "r");
+         }
+         catch (FileNotFoundException e)
+         {
+             // if file isn't present, don't return an empty stream as it looks the same as no log lines matched
+             throw new UncheckedIOException(e);
+         }
+         if (startPosition > 0) // -1 used to disable, so ignore any negative values or 0 (default offset)
+         {
+             try
+             {
+                 reader.seek(startPosition);
+             }
+             catch (IOException e)
+             {
+                 throw new UncheckedIOException("Unable to seek to " + startPosition, e);
+             }
+         }
+         return new FileLineIterator(reader, fn);
+     }
+ 
+     private static final class FileLineIterator extends AbstractIterator<String> implements LineIterator
+     {
+         private final RandomAccessFile reader;
+         private final Predicate<String> fn;
+ 
+         private FileLineIterator(RandomAccessFile reader, Predicate<String> fn)
+         {
+             this.reader = reader;
+             this.fn = fn;
+         }
+ 
+         @Override
+         public long mark()
+         {
+             try
+             {
+                 return reader.getFilePointer();
+             }
+             catch (IOException e)
+             {
+                 throw new UncheckedIOException(e);
+             }
+         }
+ 
+         @Override
+         protected String computeNext()
+         {
+             try
+             {
+                 String s;
+                 while ((s = reader.readLine()) != null)
+                 {
+                     if (fn.test(s))
+                         return s;
+                 }
+                 return endOfData();
+             }
+             catch (IOException e)
+             {
+                 throw new UncheckedIOException(e);
+             }
+         }
+ 
+         @Override
+         public void close()
+         {
+             try
+             {
+                 Closeables.close(reader, true);
+             }
+             catch (IOException impossible)
+             {
+                 throw new AssertionError(impossible);
+             }
+         }
+     }
+ }


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