Skip to content
Snippets Groups Projects
Commit 510dc7ec authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

Fixed a few bugs

#40 Kieker version of this stage removed, as it is not needed
parent d405d9bc
No related branches found
No related tags found
No related merge requests found
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);
}
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
/***************************************************************************
* 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 {
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>();
......
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