From 510dc7ecb8c8bfb2b266576470a1abda669a91d8 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Tue, 21 Oct 2014 14:41:13 +0200 Subject: [PATCH] Fixed a few bugs #40 Kieker version of this stage removed, as it is not needed --- .../java/teetime/stage/CipherByteArray.java | 21 ++- .../stage/kieker/Dir2RecordsFilter.java | 5 - .../stage/kieker/DirWithBin2RecordFilter.java | 4 +- .../stage/kieker/DirWithDat2RecordFilter.java | 4 +- .../fileToRecord/ZipFile2RecordFilter.java | 129 ------------------ .../MethodCallThroughputAnalysis17.java | 2 - 6 files changed, 19 insertions(+), 146 deletions(-) delete mode 100644 src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java diff --git a/src/main/java/teetime/stage/CipherByteArray.java b/src/main/java/teetime/stage/CipherByteArray.java index b31cf474..e260f9ab 100644 --- a/src/main/java/teetime/stage/CipherByteArray.java +++ b/src/main/java/teetime/stage/CipherByteArray.java @@ -1,8 +1,12 @@ package teetime.stage; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; @@ -33,21 +37,30 @@ public class CipherByteArray extends ConsumerStage<byte[]> { try { secretKey = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"). generateSecret(keySpec); - } catch (Exception e) { - e.printStackTrace(); + } catch (InvalidKeySpecException e1) { + throw new IllegalStateException(e1); + } catch (NoSuchAlgorithmException e1) { + throw new IllegalStateException(e1); } skeyspec = new SecretKeySpec(secretKey.getEncoded(), "AES"); try { 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) { this.cipher.init(Cipher.ENCRYPT_MODE, skeyspec); } else { this.cipher.init(Cipher.DECRYPT_MODE, skeyspec); } - } catch (Exception e) { - e.printStackTrace(); + } catch (InvalidKeyException e) { + throw new IllegalStateException(e); } } diff --git a/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java b/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java index 15ecff3f..64ea7fdb 100644 --- a/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java +++ b/src/main/java/teetime/stage/kieker/Dir2RecordsFilter.java @@ -31,7 +31,6 @@ import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; import teetime.stage.kieker.className.ClassNameRegistryRepository; import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter; import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter; -import teetime.stage.kieker.fileToRecord.ZipFile2RecordFilter; import kieker.common.record.IMonitoringRecord; import kieker.common.util.filesystem.BinaryCompressionMethod; @@ -62,14 +61,12 @@ public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilt final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(this.classNameRegistryRepository); final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(this.classNameRegistryRepository); - final ZipFile2RecordFilter zipFile2RecordFilter = new ZipFile2RecordFilter(); final Merger<IMonitoringRecord> recordMerger = new Merger<IMonitoringRecord>(); // store ports due to readability reasons final OutputPort<File> normalFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.NORMAL_FILE_EXTENSION); final OutputPort<File> binFileOutputPort = fileExtensionSwitch.addFileExtension(BinaryCompressionMethod.NONE.getFileExtension()); - final OutputPort<File> zipFileOutputPort = fileExtensionSwitch.addFileExtension(FSUtil.ZIP_FILE_EXTENSION); // connect ports by pipes IPipeFactory pipeFactory = pipeFactoryRegistry.getPipeFactory(ThreadCommunication.INTRA, PipeOrdering.ARBITRARY, false); @@ -78,11 +75,9 @@ public class Dir2RecordsFilter extends OldPipeline<ClassNameRegistryCreationFilt pipeFactory.create(normalFileOutputPort, datFile2RecordFilter.getInputPort()); pipeFactory.create(binFileOutputPort, binaryFile2RecordFilter.getInputPort()); - pipeFactory.create(zipFileOutputPort, zipFile2RecordFilter.getInputPort()); pipeFactory.create(datFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); pipeFactory.create(binaryFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); - pipeFactory.create(zipFile2RecordFilter.getOutputPort(), recordMerger.getNewInputPort()); // prepare pipeline this.setFirstStage(classNameRegistryCreationFilter); diff --git a/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java b/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java index efe06d6d..ae11d6e6 100644 --- a/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java +++ b/src/main/java/teetime/stage/kieker/DirWithBin2RecordFilter.java @@ -3,9 +3,8 @@ package teetime.stage.kieker; import java.io.File; import teetime.framework.InputPort; -import teetime.framework.OutputPort; import teetime.framework.OldPipeline; -import teetime.stage.io.Directory2FilesFilter; +import teetime.framework.OutputPort; import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; import teetime.stage.kieker.className.ClassNameRegistryRepository; import teetime.stage.kieker.fileToRecord.BinaryFile2RecordFilter; @@ -20,7 +19,6 @@ public class DirWithBin2RecordFilter extends OldPipeline<ClassNameRegistryCreati this.classNameRegistryRepository = classNameRegistryRepository; final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository); - final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter(); final BinaryFile2RecordFilter binaryFile2RecordFilter = new BinaryFile2RecordFilter(classNameRegistryRepository); this.setFirstStage(classNameRegistryCreationFilter); diff --git a/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java b/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java index 93fe14f2..ae8795bf 100644 --- a/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java +++ b/src/main/java/teetime/stage/kieker/DirWithDat2RecordFilter.java @@ -3,9 +3,8 @@ package teetime.stage.kieker; import java.io.File; import teetime.framework.InputPort; -import teetime.framework.OutputPort; import teetime.framework.OldPipeline; -import teetime.stage.io.Directory2FilesFilter; +import teetime.framework.OutputPort; import teetime.stage.kieker.className.ClassNameRegistryCreationFilter; import teetime.stage.kieker.className.ClassNameRegistryRepository; import teetime.stage.kieker.fileToRecord.DatFile2RecordFilter; @@ -20,7 +19,6 @@ public class DirWithDat2RecordFilter extends OldPipeline<ClassNameRegistryCreati this.classNameRegistryRepository = classNameRegistryRepository; final ClassNameRegistryCreationFilter classNameRegistryCreationFilter = new ClassNameRegistryCreationFilter(classNameRegistryRepository); - final Directory2FilesFilter directory2FilesFilter = new Directory2FilesFilter(); final DatFile2RecordFilter datFile2RecordFilter = new DatFile2RecordFilter(classNameRegistryRepository); this.setFirstStage(classNameRegistryCreationFilter); diff --git a/src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java b/src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java deleted file mode 100644 index e9686124..00000000 --- a/src/main/java/teetime/stage/kieker/fileToRecord/ZipFile2RecordFilter.java +++ /dev/null @@ -1,129 +0,0 @@ -/*************************************************************************** - * 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; - } - -} diff --git a/src/performancetest/java/teetime/examples/experiment17/MethodCallThroughputAnalysis17.java b/src/performancetest/java/teetime/examples/experiment17/MethodCallThroughputAnalysis17.java index b61ed4da..62345de3 100644 --- a/src/performancetest/java/teetime/examples/experiment17/MethodCallThroughputAnalysis17.java +++ b/src/performancetest/java/teetime/examples/experiment17/MethodCallThroughputAnalysis17.java @@ -112,8 +112,6 @@ public class MethodCallThroughputAnalysis17 { final ConstructorClosure<TimestampObject> inputObjectCreator) { final ObjectProducer<TimestampObject> objectProducer = new ObjectProducer<TimestampObject>(numInputObjects, inputObjectCreator); Distributor<TimestampObject> distributor = new Distributor<TimestampObject>(); - Sink<TimestampObject> sink = new Sink<TimestampObject>(); - Sink<Void> endStage = new Sink<Void>(); // UnorderedGrowablePipe.connect(objectProducer.getOutputPort(), sink.getInputPort()); // objectProducer.getOutputPort().pipe = new UnorderedGrowablePipe<TimestampObject>(); -- GitLab