Skip to content

Commit

Permalink
CASSANDRA-5791 - rebased 20150325
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffjirsa committed Mar 26, 2015
1 parent 8439345 commit daaa888
Show file tree
Hide file tree
Showing 16 changed files with 1,203 additions and 33 deletions.
55 changes: 55 additions & 0 deletions bin/sstableverify
@@ -0,0 +1,55 @@
#!/bin/sh

# 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.

if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
for include in /usr/share/cassandra/cassandra.in.sh \
/usr/local/share/cassandra/cassandra.in.sh \
/opt/cassandra/cassandra.in.sh \
~/.cassandra.in.sh \
"`dirname "$0"`/cassandra.in.sh"; do
if [ -r "$include" ]; then
. "$include"
break
fi
done
elif [ -r "$CASSANDRA_INCLUDE" ]; then
. "$CASSANDRA_INCLUDE"
fi

# Use JAVA_HOME if set, otherwise look for java in PATH
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="`which java`"
fi

if [ -z "$CLASSPATH" ]; then
echo "You must set the CLASSPATH var" >&2
exit 1
fi

if [ "x$MAX_HEAP_SIZE" = "x" ]; then
MAX_HEAP_SIZE="256M"
fi

"$JAVA" $JAVA_AGENT -ea -cp "$CLASSPATH" -Xmx$MAX_HEAP_SIZE \
-Dcassandra.storagedir="$cassandra_storagedir" \
-Dlogback.configurationFile=logback-tools.xml \
org.apache.cassandra.tools.StandaloneVerifier "$@"

# vi:ai sw=4 ts=4 tw=0 et
41 changes: 41 additions & 0 deletions bin/sstableverify.bat
@@ -0,0 +1,41 @@
@REM
@REM Licensed to the Apache Software Foundation (ASF) under one or more
@REM contributor license agreements. See the NOTICE file distributed with
@REM this work for additional information regarding copyright ownership.
@REM The ASF licenses this file to You under the Apache License, Version 2.0
@REM (the "License"); you may not use this file except in compliance with
@REM the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@REM See the License for the specific language governing permissions and
@REM limitations under the License.

@echo off
if "%OS%" == "Windows_NT" setlocal

pushd "%~dp0"
call cassandra.in.bat

if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.tools.StandaloneVerifier
if NOT DEFINED JAVA_HOME goto :err

REM ***** JAVA options *****
set JAVA_OPTS=^
-Dlogback.configurationFile=logback-tools.xml

set TOOLS_PARAMS=

"%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" %*
goto finally

:err
echo JAVA_HOME environment variable must be set!
pause

:finally

ENDLOCAL
5 changes: 5 additions & 0 deletions src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Expand Up @@ -1437,6 +1437,11 @@ public boolean rebuildOnFailedScrub(Throwable failure)
return true;
}

public CompactionManager.AllSSTableOpStatus verify(boolean extendedVerify) throws ExecutionException, InterruptedException
{
return CompactionManager.instance.performVerify(ColumnFamilyStore.this, extendedVerify);
}

public CompactionManager.AllSSTableOpStatus sstablesRewrite(boolean excludeCurrentVersion) throws ExecutionException, InterruptedException
{
return CompactionManager.instance.performSSTableRewrite(ColumnFamilyStore.this, excludeCurrentVersion);
Expand Down
36 changes: 36 additions & 0 deletions src/java/org/apache/cassandra/db/compaction/CompactionManager.java
Expand Up @@ -323,6 +323,25 @@ public void execute(SSTableReader input) throws IOException
});
}

public AllSSTableOpStatus performVerify(final ColumnFamilyStore cfs, final boolean extendedVerify) throws InterruptedException, ExecutionException
{
assert !cfs.isIndex();
return parallelAllSSTableOperation(cfs, new OneSSTableOperation()
{
@Override
public Iterable<SSTableReader> filterSSTables(Iterable<SSTableReader> input)
{
return input;
}

@Override
public void execute(SSTableReader input) throws IOException
{
verifyOne(cfs, input, extendedVerify);
}
});
}

public AllSSTableOpStatus performSSTableRewrite(final ColumnFamilyStore cfs, final boolean excludeCurrentVersion) throws InterruptedException, ExecutionException
{
return parallelAllSSTableOperation(cfs, new OneSSTableOperation()
Expand Down Expand Up @@ -651,6 +670,23 @@ private void scrubOne(ColumnFamilyStore cfs, SSTableReader sstable, boolean skip
}
}

private void verifyOne(ColumnFamilyStore cfs, SSTableReader sstable, boolean extendedVerify) throws IOException
{
Verifier verifier = new Verifier(cfs, sstable, false);

CompactionInfo.Holder verifyInfo = verifier.getVerifyInfo();
metrics.beginCompaction(verifyInfo);
try
{
verifier.verify(extendedVerify);
}
finally
{
verifier.close();
metrics.finishCompaction(verifyInfo);
}
}

/**
* Determines if a cleanup would actually remove any data in this SSTable based
* on a set of owned ranges.
Expand Down
Expand Up @@ -31,7 +31,8 @@ public enum OperationType
/** Compaction for tombstone removal */
TOMBSTONE_COMPACTION("Tombstone Compaction"),
UNKNOWN("Unknown compaction type"),
ANTICOMPACTION("Anticompaction after repair");
ANTICOMPACTION("Anticompaction after repair"),
VERIFY("Verify");

private final String type;

Expand Down

0 comments on commit daaa888

Please sign in to comment.