CPD Results

The following document contains the results of PMD's CPD

Duplications

FileLine
mupisim/net/torus/TorusAdaptiveShortestPathRoutingFunction.java73
mupisim/net/torus/TorusStaticXYRoutingFunction.java72
	protected NodeAddress getNextHopAddress(final Link incomingLink, final NodeAddress destination)
	{
		final int incomingDestinationX = GridUtil.getX(incomingLink.destination().address());
		final int incomingDestinationY = GridUtil.getY(incomingLink.destination().address());

		final int incomingSourceX;
		final int incomingSourceY;
		if (incomingLink.isInjectionLink())
		{
			incomingSourceX=	incomingDestinationX;
			incomingSourceY=	incomingDestinationY;
		}
		else
		{
			incomingSourceX=	GridUtil.getX(incomingLink.source().address());
			incomingSourceY=	GridUtil.getY(incomingLink.source().address());
		}

		// (0,0) is the upper - left corner of the grid
		final boolean incomingLeft=		MathUtil.mod(incomingSourceX + 1, width) == incomingDestinationX;
		final boolean incomingRight=	incomingSourceX == MathUtil.mod(incomingDestinationX + 1, width);
		final boolean incomingUp=		MathUtil.mod(incomingSourceY + 1, height) == incomingDestinationY;
		final boolean incomingDown=		incomingSourceY == MathUtil.mod(incomingDestinationY + 1, height);

		if (logger.isDebugEnabled())
		{
			logger.debug("  incomingLeft=" + incomingLeft
					+ " incomingRight=" + incomingRight
					+ " incomingUp=" + incomingUp
					+ " incomingDown=" + incomingDown);
		}

		assert !(incomingRight && incomingLeft);
		assert !(incomingUp && incomingDown);

		final int destinationX=	GridUtil.getX(destination);
		final int destinationY=	GridUtil.getY(destination);

		final int rightDistance=	MathUtil.mod(destinationX - incomingDestinationX, width);
		final int leftDistance=		MathUtil.mod(incomingDestinationX - destinationX, width);
		final int downDistance=		MathUtil.mod(destinationY - incomingDestinationY, height);
		final int upDistance=		MathUtil.mod(incomingDestinationY - destinationY, height);

		if (logger.isDebugEnabled())
		{
			logger.debug("  leftDistance=" + leftDistance
					+ " rightDistance=" + rightDistance
					+ " upDistance=" + upDistance
					+ " downDistance=" + downDistance);
		}

		final boolean isRight;
		final boolean isLeft;
		if (rightDistance != leftDistance)
		{
			// if rightDistance != leftDistance choose the shortest distance
			isRight=	rightDistance < leftDistance;
			isLeft=		rightDistance > leftDistance;
		}
		else if (rightDistance == 0)
		{
			// if rightDistance = 0 and leftDistance = 0, then destination neither
			// isLeft nor isRight
			assert leftDistance == 0;

			isRight = false;
			isLeft = false;
		}
		else
		{

			// if rightDistance and leftDistance are non-null and equal, then
			// destination depends on incoming direction or isRight when
			// incoming direction is null
			assert rightDistance != 0;
			assert leftDistance != 0;
			assert rightDistance == leftDistance;

			if (incomingRight)
			{
				isLeft = true;
				isRight = false;
			}
			else
			{
				isRight = true;
				isLeft = false;
			}
		}

		final boolean isUp;
		final boolean isDown;
		if (upDistance != downDistance)
		{
			// if upDistance != downDistance choose the shortest distance
			isUp=		upDistance < downDistance;
			isDown=		upDistance > downDistance;
		}
		else if (upDistance == 0)
		{
			// if upDistance = 0 and downDistance = 0, then destination neither isDown nor isUp
			assert downDistance == 0;

			isUp = false;
			isDown = false;
		}
		else
		{
			// if upDistance and downDistance are non - null and equal, then destination isUp
			assert upDistance != 0;
			assert downDistance != 0;
			assert upDistance == downDistance;

			if (incomingUp)
			{
				isUp = false;
				isDown = true;
			}
			else
			{
				isUp = true;
				isDown = false;
			}
		}

		assert !(isRight && isLeft);
		assert !(isUp && isDown);

		if (logger.isDebugEnabled())
		{
			logger.debug("  isLeft=" + isLeft
					+ " isRight=" + isRight
					+ " isUp=" + isUp
					+ " isDown=" + isDown);
		}

FileLine
mupisim/net/random/RandomRegularNetwork.java195
mupisim/net/random/RandomNetwork.java166
			assert pair != null : pairs.toString();

			// Connect the nodes
			final Node[] nodes = pair.toArray(new Node[2]);
			assert nodes.length == 2;
			assert nodes[0] != null;
			assert nodes[1] != null;
			addLink(nodes[0], nodes[1]);
			addLink(nodes[1], nodes[0]);

			// Remove the pair from the set of pairs
			pairs.remove(pair);

			// Tag the pairs of nodes to be removed (any couple involving a
			// node which already has the maximum maxDegree)
			// While there, update the probability for each pair
			final Set<Set<Node>> pairsToRemove = new LinkedHashSet<Set<Node>>(pairs.size());

			for (Set<Node> p : pairs.keySet())
			{
				final Node n1 = p.toArray(new Node[2])[0];
				final Node n2 = p.toArray(new Node[2])[1];

				final int d1 = NetworkUtil.degree(this, n1);
				final int d2 = NetworkUtil.degree(this, n2);

FileLine
mupisim/Mupisim.java166
mupisim/BuildNetwork.java148
				overrideConfiguration.load(Mupisim.OVERRIDE_CONFIGURATION);
				configuration.addConfiguration(overrideConfiguration);
			}

			// User configuration
			final PropertiesConfiguration userConfiguration = new PropertiesConfiguration();
			userConfiguration.load(propertiesFilename);
			configuration.addConfiguration(userConfiguration);

			// Default configuration
			final PropertiesConfiguration defaultConfiguration = new PropertiesConfiguration();
			final URL defaultConfigurationURL = Mupisim.class.getClassLoader().getResource("Mupisim.properties");
			if (defaultConfigurationURL != null)
			{
				defaultConfiguration.load(defaultConfigurationURL);
				configuration.addConfiguration(defaultConfiguration);
			}

			// Dump configuration
			if (logger.isDebugEnabled())
			{
				logger.debug("\n" + ConfigurationUtils.toString(configuration.subset("mupisim")));
			}

		}
		catch (ConfigurationException e)
		{
			throw ExceptionUtil.toRuntimeException(e);
		}

		// Container
		final Container container = new Container(configuration);

FileLine
mupisim/event/AbstractEventObservable.java38
mupisim/event/AbstractLogEnabledEventObservable.java41
	public AbstractObservableSimulationComponent()
	{
		super();
	}


	public void setEventScheduler(final EventScheduler eventScheduler)
	{
		assert !initialized;
		assert eventScheduler != null;
		assert this.eventScheduler == null;

		this.eventScheduler = eventScheduler;
	}


	public void initialize()
	{
		assert !initialized;

		// Event observable
		assert eventScheduler != null;
		eventObservable = new ScheduledEventObservable(eventScheduler);

		initialized = true;
	}


	public void fireEvent(final MupisimEvent event)
	{
		assert eventObservable != null;

		eventObservable.fireEvent(event);
	}


	public void addEventObserver(final EventObserver observer)
	{
		assert eventObservable != null;

		eventObservable.addEventObserver(observer);
	}


	public void removeEventObserver(final EventObserver observer)
	{
		assert eventObservable != null;

		eventObservable.removeEventObserver(observer);
	}
}

FileLine
mupisim/sim/mobile/WeakPiControlProcess.java46
mupisim/sim/mobile/PiControlProcess.java132
	}


	protected boolean isREquivalent(final NodeAddress address1, final NodeAddress address2)
	{
		if (address1.equals(address2))
		{
			return true;
		}

		final Set<Link> inputLinks = network.getInputLinks(host());
		if (logger.isDebugEnabled())
		{
			logger.debug("inputLinks= " + inputLinks);
		}

		for (Link link : inputLinks)
		{
			assert !link.isDeliveryLink();

			final Set<Link> outputLinks1 = routingFunction.getOutputLinks(link, address1);
			final Set<Link> outputLinks2 = routingFunction.getOutputLinks(link, address2);

			if (!outputLinks1.equals(outputLinks2))

FileLine
mupisim/net/torus/TorusAdaptiveShortestPathRoutingFunction.java232
mupisim/net/torus/TorusStaticXYRoutingFunction.java233
	}


	public Set<Link> getOutputLinks(final Link incomingLink, final NodeAddress destination)
	{
		assert initialized;

		if (logger.isDebugEnabled())
		{
			logger.debug("getOutputLinks(" + incomingLink + ", " + destination + ")");
		}

		assert incomingLink != null;
		assert destination != null;
		assert !incomingLink.isDeliveryLink();

		if (incomingLink.isDeliveryLink())
		{
			return Collections.EMPTY_SET;
		}

		if (incomingLink.destination().address().equals(destination))
		{
			return Collections.singleton(network.getDeliveryLink(destination));
		}

		final NodeAddress nextHopAddress = getNextHopAddress(incomingLink, destination);