Commit 9dd1f056 authored by Christian Wulf's avatar Christian Wulf

reduced some visibilities

parent 93f3676b
......@@ -328,6 +328,9 @@
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<configLocation>${project.basedir}/conf/quality-config/cs-conf.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
......@@ -337,9 +340,6 @@
<failOnViolation>false</failOnViolation>
<linkXRef>false</linkXRef>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
......@@ -349,13 +349,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.version}</version>
<configuration>
<effort>Max</effort>
<threshold>Max</threshold>
<includeTests>true</includeTests>
<failOnError>true</failOnError>
<excludeFilterFile>${project.basedir}/conf/quality-config/fb-filter.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<phase>test</phase>
......@@ -364,6 +357,13 @@
</goals>
</execution>
</executions>
<configuration>
<effort>Max</effort>
<threshold>Max</threshold>
<includeTests>true</includeTests>
<failOnError>true</failOnError>
<excludeFilterFile>${project.basedir}/conf/quality-config/fb-filter.xml</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>junit</groupId>
......@@ -383,6 +383,15 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>pmd</goal>
<goal>cpd</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sourceforge.teetime</groupId>
......@@ -401,15 +410,7 @@
<!-- <failurePriority>1</failurePriority> -->
<failOnViolation>true</failOnViolation>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>pmd</goal>
<goal>cpd</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -490,6 +491,37 @@
</dependency>
</dependencies>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-checkstyle-plugin
</artifactId>
<versionRange>
[3.0.0,)
</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
......
......@@ -15,20 +15,19 @@
*/
package teetime.framework;
import teetime.framework.pipe.AbstractSynchedPipe;
import teetime.framework.pipe.AbstractUnsynchedPipe;
import teetime.framework.pipe.IPipe;
import teetime.framework.scheduling.PipeScheduler;
/**
* Represents an abstract implementation of a {@link IPipe}.
* Represents an abstract implementation of an {@link teetime.framework.pipe.IPipe}.
*
* @author Christian Wulf (chw)
*
* @param <T>
* the type of the elements which this pipe should transfer.
*
* @deprecated since 3.0. Use {@link teetime.framework.pipe.AbstractPipe} instead.
*/
@Deprecated
public abstract class AbstractPipe<T> implements IPipe<T> {
protected final AbstractStage cachedTargetStage;
......@@ -36,7 +35,24 @@ public abstract class AbstractPipe<T> implements IPipe<T> {
private final OutputPort<? extends T> sourcePort;
private final InputPort<T> targetPort;
private PipeScheduler scheduler;
// FIXME each scheduler should set a default pipe scheduler by its own
private PipeScheduler scheduler = new PipeScheduler() {
@Override
public void onElementAdded(final AbstractSynchedPipe<?> pipe) {
// do nothing
}
@Override
public void onElementAdded(final AbstractUnsynchedPipe<?> pipe) {
// do nothing
}
@Override
public void onElementNotAdded(final AbstractSynchedPipe<?> pipe) {
// do nothing
}
};
protected AbstractPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) {
if (sourcePort == null) {
......
......@@ -58,7 +58,7 @@ public class AbstractPort<T> {
return this.pipe;
}
public void setPipe(final IPipe<?> pipe) {
/* default */ void setPipe(final IPipe<?> pipe) {
this.pipe = pipe;
}
......
......@@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.List;
import teetime.framework.pipe.DummyPipe;
import teetime.framework.pipe.InstantiationPipe;
/**
* Represents a minimal stage that composes several other stages.
......@@ -95,11 +94,11 @@ public class CompositeStage {
return subStageOutputPort;
}
public List<InputPort<?>> getInputPorts() {
List<InputPort<?>> getInputPorts() {
return inputPorts;
}
public List<OutputPort<?>> getOutputPorts() {
List<OutputPort<?>> getOutputPorts() {
return outputPorts;
}
......
......@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package teetime.framework.pipe;
package teetime.framework;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.pipe.IPipe;
import teetime.framework.scheduling.PipeScheduler;
import teetime.framework.signal.ISignal;
......
......@@ -21,7 +21,7 @@ import teetime.framework.exceptionHandling.AbstractExceptionListener;
import teetime.framework.exceptionHandling.TerminateException;
/**
* Used to access the package-private methods of {@link AbstractStage}.
* Used to access the package-private methods of {@link AbstractStage} and {@link CompositeStage}.
*
* @author Christian Wulf (chw)
*
......@@ -38,6 +38,10 @@ public final class StageFacade {
stage.abort();
}
/**
* @deprecated since 3.0. Will be removed.
*/
@Deprecated
public TerminationStrategy getTerminationStrategy(final AbstractStage stage) {
return stage.getTerminationStrategy();
}
......@@ -98,10 +102,18 @@ public final class StageFacade {
return stage.getInputPorts();
}
public List<InputPort<?>> getInputPorts(final CompositeStage stage) {
return stage.getInputPorts();
}
public List<OutputPort<?>> getOutputPorts(final AbstractStage stage) {
return stage.getOutputPorts();
}
public List<OutputPort<?>> getOutputPorts(final CompositeStage stage) {
return stage.getOutputPorts();
}
public int getLevelIndex(final AbstractStage stage) {
return stage.getLevelIndex();
}
......
/**
* Copyright © 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime-framework.github.io)
*
* 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.framework.pipe;
import teetime.framework.AbstractStage;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.scheduling.PipeScheduler;
/**
* Represents an abstract implementation of a {@link IPipe}.
*
* @author Christian Wulf (chw)
*
* @param <T>
* the type of the elements which this pipe should transfer.
*/
public abstract class AbstractPipe<T> implements IPipe<T> {
protected final AbstractStage cachedTargetStage;
private final OutputPort<? extends T> sourcePort;
private final InputPort<T> targetPort;
// FIXME each scheduler should set a default pipe scheduler by its own
private PipeScheduler scheduler = new PipeScheduler() {
@Override
public void onElementAdded(final AbstractSynchedPipe<?> pipe) {
// do nothing
}
@Override
public void onElementAdded(final AbstractUnsynchedPipe<?> pipe) {
// do nothing
}
@Override
public void onElementNotAdded(final AbstractSynchedPipe<?> pipe) {
// do nothing
}
};
protected AbstractPipe(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort) {
if (sourcePort == null) {
throw new IllegalArgumentException("sourcePort may not be null");
}
if (targetPort == null) {
throw new IllegalArgumentException("targetPort may not be null");
}
sourcePort.setPipe(this);
targetPort.setPipe(this);
this.sourcePort = sourcePort;
this.targetPort = targetPort;
this.cachedTargetStage = targetPort.getOwningStage();
}
@Override
public final OutputPort<? extends T> getSourcePort() {
return sourcePort;
}
@Override
public final InputPort<T> getTargetPort() {
return targetPort;
}
@Override
public final boolean hasMore() {
return !isEmpty();
}
/**
* Performance cache: Avoids the following method chain
*
* <pre>
* this.getTargetPort().getOwningStage()
* </pre>
*/
public AbstractStage getCachedTargetStage() {
return cachedTargetStage;
}
protected PipeScheduler getScheduler() {
return scheduler;
}
@Override
public void setScheduler(final PipeScheduler scheduler) {
if (scheduler == null) {
throw new IllegalArgumentException("Argument 'scheduler' may not be null");
}
this.scheduler = scheduler;
}
@Override
public String toString() {
return sourcePort.getOwningStage().getId() + " -> " + targetPort.getOwningStage().getId() + " (" + super.toString() + ")";
}
}
......@@ -23,6 +23,7 @@ import org.jctools.queues.spec.ConcurrentQueueSpec;
import org.jctools.queues.spec.Ordering;
import org.jctools.queues.spec.Preference;
import teetime.framework.AbstractPipe;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.signal.ISignal;
......
......@@ -15,6 +15,7 @@
*/
package teetime.framework.pipe;
import teetime.framework.AbstractPipe;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.signal.ISignal;
......
......@@ -21,13 +21,9 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import teetime.framework.AbstractPort;
import teetime.framework.AbstractStage;
import teetime.framework.ITraverserVisitor;
import teetime.framework.Traverser;
import teetime.framework.*;
import teetime.framework.pipe.DummyPipe;
import teetime.framework.pipe.IPipe;
import teetime.framework.pipe.InstantiationPipe;
import teetime.framework.scheduling.PipeScheduler;
/**
......
/**
* Copyright © 2015 Christian Wulf, Nelson Tavares de Sousa (http://teetime-framework.github.io)
*
* 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.framework.scheduling.globaltaskpool;
import java.util.Queue;
import org.jctools.queues.QueueFactory;
import org.jctools.queues.spec.ConcurrentQueueSpec;
import org.jctools.queues.spec.Ordering;
import org.jctools.queues.spec.Preference;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.pipe.IPipe;
import teetime.framework.scheduling.PipeScheduler;
import teetime.framework.signal.ISignal;
/**
* Created by nilsziermann on 04.01.17.
*/
class TaskQueueBufferPipe<T> implements IPipe<T> {
private final Queue<Object> queue;
private final InputPort<T> targetPort;
private final OutputPort<? extends T> sourcePort;
private final IPipe<? extends T> replacedPipe;
public TaskQueueBufferPipe(final InputPort<T> targetPort, final OutputPort<? extends T> sourcePort, final IPipe<? extends T> replacedPipe) {
this.targetPort = targetPort;
if (this.targetPort != null) {
this.targetPort.setPipe(this);
}
this.sourcePort = sourcePort;
if (this.sourcePort != null) {
this.sourcePort.setPipe(this);
}
this.replacedPipe = replacedPipe;
ConcurrentQueueSpec specification = new ConcurrentQueueSpec(1, 1, 0, Ordering.FIFO, Preference.THROUGHPUT);
this.queue = QueueFactory.newQueue(specification);
}
@Override
public void add(final Object element) {
boolean added = queue.offer(element);
if (!added) {
throw new IllegalStateException();
}
}
@Override
public boolean addNonBlocking(final Object element) {
return queue.offer(element);
}
@Override
public boolean isEmpty() {
return queue.size() == 0;
}
@Override
public int size() {
return queue.size();
}
@Override
public int capacity() {
return Integer.MAX_VALUE;
}
@Override
public Object removeLast() {
return queue.remove();
}
@Override
public OutputPort<? extends T> getSourcePort() {
return sourcePort;
}
@Override
public InputPort<T> getTargetPort() {
return targetPort;
}
@Override
public void sendSignal(final ISignal signal) {
}
@Override
public void reportNewElement() {
}
@Override
public boolean isClosed() {
return false;
}
@Override
public boolean hasMore() {
return !isEmpty();
}
@Override
public void waitForStartSignal() throws InterruptedException {
}
@Override
public void close() {
}
public IPipe<? extends T> getReplacedPipe() {
return replacedPipe;
}
@Override
public void setScheduler(final PipeScheduler scheduler) {
// do nothing
}
}
......@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
import teetime.framework.AbstractPort;
import teetime.framework.AbstractStage;
import teetime.framework.ITraverserVisitor;
import teetime.framework.InstantiationPipe;
import teetime.framework.Traverser.VisitorBehavior;
import teetime.framework.pipe.*;
import teetime.framework.scheduling.PipeScheduler;
......
......@@ -2,9 +2,7 @@ package teetime.framework.test;
import java.util.List;
import teetime.framework.CompositeStage;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.*;
class CompositeStageUnderTest implements StageUnderTest {
......@@ -12,22 +10,33 @@ class CompositeStageUnderTest implements StageUnderTest {
public CompositeStageUnderTest(final CompositeStage compositeStage) {
this.compositeStage = compositeStage;
List<InputPort<?>> inputPorts = StageFacade.INSTANCE.getInputPorts(compositeStage);
for (InputPort<?> inputPort : inputPorts) {
AbstractStage stage = inputPort.getOwningStage();
if (stage.getCurrentState() != StageState.CREATED) {
String message = "This stage has already been tested in this test method. Move this test into a new test method.";
throw new InvalidTestCaseSetupException(message);
}
}
}
@Override
public List<InputPort<?>> getInputPorts() {
return compositeStage.getInputPorts();
return StageFacade.INSTANCE.getInputPorts(compositeStage);
}
@Override
public List<OutputPort<?>> getOutputPorts() {
return compositeStage.getOutputPorts();
return StageFacade.INSTANCE.getOutputPorts(compositeStage);
}
@Override
public void declareActive() {
// TODO Auto-generated method stub
for (InputPort<?> inputPort : getInputPorts()) {
inputPort.getOwningStage().declareActive();
}
// do nothing
}
}
......@@ -2,10 +2,7 @@ package teetime.framework.test;
import java.util.List;
import teetime.framework.AbstractStage;
import teetime.framework.InputPort;
import teetime.framework.OutputPort;
import teetime.framework.StageFacade;
import teetime.framework.*;
class PrimitiveStageUnderTest implements StageUnderTest {
......@@ -13,6 +10,12 @@ class PrimitiveStageUnderTest implements StageUnderTest {
public PrimitiveStageUnderTest(final AbstractStage stage) {
this.stage = stage;
if (stage.getCurrentState() != StageState.CREATED) {
String message = "This stage has already been tested in this test method. Move this test into a new test method.";
throw new InvalidTestCaseSetupException(message);
}
}
@Override
......
......@@ -51,11 +51,6 @@ public class StageTester {
public static StageTester test(final AbstractStage stage) {
StageUnderTest stageUnderTest = new PrimitiveStageUnderTest(stage);
if (stage.getCurrentState() != StageState.CREATED) {
String message = "This stage has already been tested in this test method. Move this test into a new test method.";
throw new InvalidTestCaseSetupException(message);
}