Skip to content
Snippets Groups Projects
Commit 3fc15c75 authored by Christian Wulf's avatar Christian Wulf
Browse files

Merge branch 'findbugs' into 'master'

Findbugs

Related to #57

See merge request !10
parents b30bd4c2 a8e7c80e
No related branches found
No related tags found
No related merge requests found
Showing with 161 additions and 155 deletions
#FindBugs User Preferences #FindBugs User Preferences
#Mon Oct 20 12:37:59 CEST 2014 #Wed Oct 22 08:03:09 CEST 2014
cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
detectorAtomicityProblem=AtomicityProblem|true
detectorBadAppletConstructor=BadAppletConstructor|false
detectorBadResultSetAccess=BadResultSetAccess|true
detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
detectorBadUseOfReturnValue=BadUseOfReturnValue|true
detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
detectorBooleanReturnNull=BooleanReturnNull|true
detectorCallToUnsupportedMethod=CallToUnsupportedMethod|true
detectorCheckExpectedWarnings=CheckExpectedWarnings|true
detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
detectorCheckRelaxingNullnessAnnotation=CheckRelaxingNullnessAnnotation|true
detectorCheckTypeQualifiers=CheckTypeQualifiers|true
detectorCloneIdiom=CloneIdiom|true
detectorComparatorIdiom=ComparatorIdiom|true
detectorConfusedInheritance=ConfusedInheritance|true
detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
detectorCrossSiteScripting=CrossSiteScripting|true
detectorDefaultEncodingDetector=DefaultEncodingDetector|true
detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
detectorDontUseEnum=DontUseEnum|true
detectorDroppedException=DroppedException|true
detectorDumbMethodInvocations=DumbMethodInvocations|true
detectorDumbMethods=DumbMethods|true
detectorDuplicateBranches=DuplicateBranches|true
detectorEmptyZipFileEntry=EmptyZipFileEntry|true
detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
detectorExplicitSerialization=ExplicitSerialization|true
detectorFinalizerNullsFields=FinalizerNullsFields|true
detectorFindBadCast2=FindBadCast2|true
detectorFindBadForLoop=FindBadForLoop|true
detectorFindCircularDependencies=FindCircularDependencies|true
detectorFindDeadLocalStores=FindDeadLocalStores|true
detectorFindDoubleCheck=FindDoubleCheck|true
detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
detectorFindFinalizeInvocations=FindFinalizeInvocations|true
detectorFindFloatEquality=FindFloatEquality|true
detectorFindHEmismatch=FindHEmismatch|true
detectorFindInconsistentSync2=FindInconsistentSync2|true
detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
detectorFindMaskedFields=FindMaskedFields|true
detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
detectorFindNakedNotify=FindNakedNotify|true
detectorFindNonShortCircuit=FindNonShortCircuit|true
detectorFindNullDeref=FindNullDeref|true
detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
detectorFindOpenStream=FindOpenStream|true
detectorFindPuzzlers=FindPuzzlers|true
detectorFindRefComparison=FindRefComparison|true
detectorFindReturnRef=FindReturnRef|true
detectorFindRoughConstants=FindRoughConstants|true
detectorFindRunInvocations=FindRunInvocations|true
detectorFindSelfComparison=FindSelfComparison|true
detectorFindSelfComparison2=FindSelfComparison2|true
detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
detectorFindSpinLoop=FindSpinLoop|true
detectorFindSqlInjection=FindSqlInjection|true
detectorFindTwoLockWait=FindTwoLockWait|true
detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
detectorFindUnconditionalWait=FindUnconditionalWait|true
detectorFindUninitializedGet=FindUninitializedGet|true
detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
detectorFindUnreleasedLock=FindUnreleasedLock|true
detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
detectorFindUnsyncGet=FindUnsyncGet|true
detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
detectorFindUselessControlFlow=FindUselessControlFlow|true
detectorFormatStringChecker=FormatStringChecker|true
detectorHugeSharedStringConstants=HugeSharedStringConstants|true
detectorIDivResultCastToDouble=IDivResultCastToDouble|true
detectorIncompatMask=IncompatMask|true
detectorInconsistentAnnotations=InconsistentAnnotations|true
detectorInefficientIndexOf=InefficientIndexOf|true
detectorInefficientMemberAccess=InefficientMemberAccess|true
detectorInefficientToArray=InefficientToArray|true
detectorInfiniteLoop=InfiniteLoop|true
detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
detectorInitializationChain=InitializationChain|true
detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true
detectorInstantiateStaticClass=InstantiateStaticClass|true
detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
detectorInvalidJUnitTest=InvalidJUnitTest|true
detectorIteratorIdioms=IteratorIdioms|true
detectorLazyInit=LazyInit|true
detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
detectorMethodReturnCheck=MethodReturnCheck|true
detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
detectorMutableLock=MutableLock|true
detectorMutableStaticFields=MutableStaticFields|true
detectorNaming=Naming|true
detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
detectorNumberConstructor=NumberConstructor|true
detectorOptionalReturnNull=OptionalReturnNull|true
detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
detectorPublicSemaphores=PublicSemaphores|true
detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
detectorRedundantInterfaces=RedundantInterfaces|true
detectorRepeatedConditionals=RepeatedConditionals|true
detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
detectorSerializableIdiom=SerializableIdiom|true
detectorStartInConstructor=StartInConstructor|true
detectorStaticCalendarDetector=StaticCalendarDetector|true
detectorStringConcatenation=StringConcatenation|true
detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
detectorSwitchFallthrough=SwitchFallthrough|true
detectorSynchronizationOnSharedBuiltinConstant=SynchronizationOnSharedBuiltinConstant|true
detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
detectorURLProblems=URLProblems|true
detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
detectorUnnecessaryMath=UnnecessaryMath|true
detectorUnreadFields=UnreadFields|true
detectorUselessSubclassMethod=UselessSubclassMethod|true
detectorVarArgsProblems=VarArgsProblems|true
detectorVolatileUsage=VolatileUsage|true
detectorWaitInLoop=WaitInLoop|true
detectorWrongMapIterator=WrongMapIterator|true
detectorXMLFactoryBypass=XMLFactoryBypass|true
detector_threshold=3 detector_threshold=3
effort=max effort=max
excludefilter0=.fbExcludeFilterFile|true excludefilter0=.fbExcludeFilterFile|true
......
eclipse.preferences.version=1
edu.umd.cs.findbugs.plugin.eclipse.findbugsMarkerScariest=Error
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java=UTF-8 encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8 encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8 encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8
package teetime.stage; package teetime.stage;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec; import java.security.spec.KeySpec;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory; import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEKeySpec;
...@@ -33,21 +37,30 @@ public class CipherByteArray extends ConsumerStage<byte[]> { ...@@ -33,21 +37,30 @@ public class CipherByteArray extends ConsumerStage<byte[]> {
try { try {
secretKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"). secretKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1").
generateSecret(keySpec); generateSecret(keySpec);
} catch (Exception e) { } catch (InvalidKeySpecException e1) {
e.printStackTrace(); throw new IllegalStateException(e1);
} catch (NoSuchAlgorithmException e1) {
throw new IllegalStateException(e1);
} }
skeyspec = new SecretKeySpec(secretKey.getEncoded(), "AES"); skeyspec = new SecretKeySpec(secretKey.getEncoded(), "AES");
try { try {
this.cipher = Cipher.getInstance(skeyspec.getAlgorithm()); this.cipher = Cipher.getInstance(skeyspec.getAlgorithm());
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
} catch (NoSuchPaddingException e) {
throw new IllegalStateException(e);
}
try {
if (mode == CipherMode.ENCRYPT) { if (mode == CipherMode.ENCRYPT) {
this.cipher.init(Cipher.ENCRYPT_MODE, skeyspec); this.cipher.init(Cipher.ENCRYPT_MODE, skeyspec);
} else { } else {
this.cipher.init(Cipher.DECRYPT_MODE, skeyspec); this.cipher.init(Cipher.DECRYPT_MODE, skeyspec);
} }
} catch (Exception e) { } catch (InvalidKeyException e) {
e.printStackTrace(); throw new IllegalStateException(e);
} }
} }
......
...@@ -18,9 +18,9 @@ package teetime.stage.io; ...@@ -18,9 +18,9 @@ package teetime.stage.io;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import teetime.framework.ProducerStage; import teetime.framework.ProducerStage;
...@@ -76,12 +76,13 @@ public class DbReader extends ProducerStage<IMonitoringRecord> { ...@@ -76,12 +76,13 @@ public class DbReader extends ProducerStage<IMonitoringRecord> {
Connection connection = null; Connection connection = null;
try { try {
connection = DriverManager.getConnection(this.connectionString); connection = DriverManager.getConnection(this.connectionString);
Statement getIndexTable = null; PreparedStatement getIndexTable = null;
try { try {
getIndexTable = connection.createStatement(); getIndexTable = connection.prepareStatement("SELECT * from ?");
getIndexTable.setString(1, this.tablePrefix);
ResultSet indexTable = null; ResultSet indexTable = null;
try { // NOCS (nested try) try { // NOCS (nested try)
indexTable = getIndexTable.executeQuery("SELECT * from " + this.tablePrefix); indexTable = getIndexTable.executeQuery();
while (this.running && indexTable.next()) { while (this.running && indexTable.next()) {
final String tablename = indexTable.getString(1); final String tablename = indexTable.getString(1);
final String classname = indexTable.getString(2); final String classname = indexTable.getString(2);
...@@ -156,12 +157,13 @@ public class DbReader extends ProducerStage<IMonitoringRecord> { ...@@ -156,12 +157,13 @@ public class DbReader extends ProducerStage<IMonitoringRecord> {
*/ */
private void table2record(final Connection connection, final String tablename, final Class<? extends IMonitoringRecord> clazz) private void table2record(final Connection connection, final String tablename, final Class<? extends IMonitoringRecord> clazz)
throws SQLException, MonitoringRecordException { throws SQLException, MonitoringRecordException {
Statement selectRecord = null; PreparedStatement selectRecord = null;
try { try {
selectRecord = connection.createStatement(); selectRecord = connection.prepareStatement("SELECT * from ?");
selectRecord.setString(1, tablename);
ResultSet records = null; ResultSet records = null;
try { try {
records = selectRecord.executeQuery("SELECT * from " + tablename); records = selectRecord.executeQuery();
final int size = records.getMetaData().getColumnCount() - 2; // remove index column final int size = records.getMetaData().getColumnCount() - 2; // remove index column
while (this.running && records.next()) { while (this.running && records.next()) {
final Object[] recordValues = new Object[size]; final Object[] recordValues = new Object[size];
......
...@@ -31,7 +31,6 @@ import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; ...@@ -31,7 +31,6 @@ import teetime.stage.kieker.className.ClassNameRegistryCreationFilter;
import teetime.stage.kieker.className.ClassNameRegistryRepository; import teetime.stage.kieker.className.ClassNameRegistryRepository;
import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter; import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter;
import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter; import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter;
import teetime.stage.kieker.fileToRecord.ZipFile2RecordFilter;
import kieker.common.record.IMonitoringRecord; import kieker.common.record.IMonitoringRecord;
import kieker.common.util.filesystem.BinaryCompressionMethod; import kieker.common.util.filesystem.BinaryCompressionMethod;
...@@ -62,14 +61,12 @@ public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilt ...@@ -62,14 +61,12 @@ public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilt
final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(this.classNameRegistryRepository); final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(this.classNameRegistryRepository);
final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(this.classNameRegistryRepository); final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(this.classNameRegistryRepository);
final ZipFile2RecordFilter zipFile2RecordFilter = new ZipFile2RecordFilter();
final Merger<IMonitoringRecord> recordMerger = new Merger<IMonitoringRecord>(); final Merger<IMonitoringRecord> recordMerger = new Merger<IMonitoringRecord>();
// store ports due to readability reasons // store ports due to readability reasons
final OutputPort<File> normalFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.NORMAL_FILE_EXTENSION); final OutputPort<File> normalFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.NORMAL_FILE_EXTENSION);
final OutputPort<File> binFileOutputPort = fileExtensionSwitch.addFileExtension(BinaryCompressionMethod.NONE.getFileExtension()); final OutputPort<File> binFileOutputPort = fileExtensionSwitch.addFileExtension(BinaryCompressionMethod.NONE.getFileExtension());
final OutputPort<File> zipFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.ZIP_FILE_EXTENSION);
// connect ports by pipes // connect ports by pipes
IPipeFactory pipeFactory = pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false); IPipeFactory pipeFactory = pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false);
...@@ -78,11 +75,9 @@ public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilt ...@@ -78,11 +75,9 @@ public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilt
pipeFactory.create(normalFileOutputPort, datFile2RecordFilter.getInputPort()); pipeFactory.create(normalFileOutputPort, datFile2RecordFilter.getInputPort());
pipeFactory.create(binFileOutputPort, binaryFile2RecordFilter.getInputPort()); pipeFactory.create(binFileOutputPort, binaryFile2RecordFilter.getInputPort());
pipeFactory.create(zipFileOutputPort, zipFile2RecordFilter.getInputPort());
pipeFactory.create(datFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); pipeFactory.create(datFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort());
pipeFactory.create(binaryFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); pipeFactory.create(binaryFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort());
pipeFactory.create(zipFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort());
// prepare pipeline // prepare pipeline
this.setFirstStage(classNameRegistryCreationFilter); this.setFirstStage(classNameRegistryCreationFilter);
......
...@@ -3,9 +3,8 @@ package teetime.stage.kieker; ...@@ -3,9 +3,8 @@ package teetime.stage.kieker;
import java.io.File; import java.io.File;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.OldPipeline; import teetime.framework.OldPipeline;
import teetime.stage.io.Directory2FilesFilter; import teetime.framework.OutputPort;
import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; import teetime.stage.kieker.className.ClassNameRegistryCreationFilter;
import teetime.stage.kieker.className.ClassNameRegistryRepository; import teetime.stage.kieker.className.ClassNameRegistryRepository;
import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter; import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter;
...@@ -20,7 +19,6 @@ public class DirWithBin2RecordFilter extends OldPipeline<ClassNameRegistryCreati ...@@ -20,7 +19,6 @@ public class DirWithBin2RecordFilter extends OldPipeline<ClassNameRegistryCreati
this.classNameRegistryRepository = classNameRegistryRepository; this.classNameRegistryRepository = classNameRegistryRepository;
final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository); final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository);
final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter();
final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(classNameRegistryRepository); final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(classNameRegistryRepository);
this.setFirstStage(classNameRegistryCreationFilter); this.setFirstStage(classNameRegistryCreationFilter);
......
...@@ -3,9 +3,8 @@ package teetime.stage.kieker; ...@@ -3,9 +3,8 @@ package teetime.stage.kieker;
import java.io.File; import java.io.File;
import teetime.framework.InputPort; import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.OldPipeline; import teetime.framework.OldPipeline;
import teetime.stage.io.Directory2FilesFilter; import teetime.framework.OutputPort;
import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; import teetime.stage.kieker.className.ClassNameRegistryCreationFilter;
import teetime.stage.kieker.className.ClassNameRegistryRepository; import teetime.stage.kieker.className.ClassNameRegistryRepository;
import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter; import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter;
...@@ -20,7 +19,6 @@ public class DirWithDat2RecordFilter extends OldPipeline<ClassNameRegistryCreati ...@@ -20,7 +19,6 @@ public class DirWithDat2RecordFilter extends OldPipeline<ClassNameRegistryCreati
this.classNameRegistryRepository = classNameRegistryRepository; this.classNameRegistryRepository = classNameRegistryRepository;
final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository); final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository);
final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter();
final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(classNameRegistryRepository); final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(classNameRegistryRepository);
this.setFirstStage(classNameRegistryCreationFilter); this.setFirstStage(classNameRegistryCreationFilter);
......
/***************************************************************************
* Copyright 2014 Kieker Project (http://kieker-monitoring.net)
*
* Licensed 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 teetime.stage.kieker.fileToRecord;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import teetime.framework.ConsumerStage;
import teetime.framework.OutputPort;
import teetime.stage.kieker.className.ClassNameRegistry;
import teetime.stage.kieker.className.MappingFileParser;
import kieker.common.record.IMonitoringRecord;
import kieker.common.util.filesystem.FSUtil;
/**
* @author Christian Wulf
*
* @since 1.10
*/
public class ZipFile2RecordFilter extends ConsumerStage<File> {
private final OutputPort<IMonitoringRecord> outputPort = this.createOutputPort();
private final MappingFileParser mappingFileParser;
/**
* @since 1.10
*/
public ZipFile2RecordFilter() {
this.mappingFileParser = new MappingFileParser(this.logger);
}
@Override
protected void execute(final File zipFile) {
final InputStream mappingFileInputStream = this.findMappingFileInputStream(zipFile);
if (mappingFileInputStream == null) {
return;
}
final ClassNameRegistry classNameRegistry = this.mappingFileParser.parseFromStream(mappingFileInputStream);
try {
this.createAndSendRecordsFromZipFile(zipFile, classNameRegistry);
} catch (final FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void createAndSendRecordsFromZipFile(final File zipFile, final ClassNameRegistry classNameRegistry)
throws FileNotFoundException {
final ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFile));
final BufferedReader reader;
try {
reader = new BufferedReader(new InputStreamReader(zipInputStream, FSUtil.ENCODING));
} catch (final UnsupportedEncodingException e) {
this.logger.error("This exception should never occur.", e);
return;
}
final DataInputStream input = new DataInputStream(new BufferedInputStream(zipInputStream, 1024 * 1024));
ZipEntry zipEntry;
try {
while (null != (zipEntry = zipInputStream.getNextEntry())) { // NOCS NOPMD
final String filename = zipEntry.getName();
// TODO implement the zip filter
}
} catch (final IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private InputStream findMappingFileInputStream(final File zipFile) {
ZipInputStream zipInputStream = null;
try {
zipInputStream = new ZipInputStream(new FileInputStream(zipFile));
ZipEntry zipEntry;
while ((null != (zipEntry = zipInputStream.getNextEntry())) && !zipEntry.getName().equals(FSUtil.MAP_FILENAME)) { // NOCS NOPMD
// do nothing, just skip to the map file if present
}
if (null == zipEntry) {
this.logger.error("The zip file does not contain a Kieker log: " + zipFile.toString());
return null;
}
return zipInputStream;
} catch (final IOException ex) {
this.logger.error("Error accessing ZipInputStream", ex);
} finally {
if (null != zipInputStream) {
try {
zipInputStream.close();
} catch (final IOException ex) {
this.logger.error("Failed to close ZipInputStream", ex);
}
}
}
return null;
}
public OutputPort<IMonitoringRecord> getOutputPort() {
return outputPort;
}
}
...@@ -112,8 +112,6 @@ public class MethodCallThroughputAnalysis17 { ...@@ -112,8 +112,6 @@ public class MethodCallThroughputAnalysis17 {
final ConstructorClosure<TimestampObject> inputObjectCreator) { final ConstructorClosure<TimestampObject> inputObjectCreator) {
final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(numInputObjects, inputObjectCreator); final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(numInputObjects, inputObjectCreator);
Distributor<TimestampObject> distributor = new Distributor<TimestampObject>(); Distributor<TimestampObject> distributor = new Distributor<TimestampObject>();
Sink<TimestampObject> sink = new Sink<TimestampObject>();
Sink<Void> endStage = new Sink<Void>();
// UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), sink.getInputPort()); // UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), sink.getInputPort());
// objectProducer.getOutputPort().pipe = new UnorderedGrowablePipe<TimestampObject>(); // objectProducer.getOutputPort().pipe = new UnorderedGrowablePipe<TimestampObject>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment