All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zulia.server.index.router.NodeRequestRouter Maven / Gradle / Ivy

There is a newer version: 1.6.4
Show newest version
package io.zulia.server.index.router;

import io.zulia.message.ZuliaBase.MasterSlaveSettings;
import io.zulia.message.ZuliaBase.Node;
import io.zulia.server.index.MasterSlaveSelector;
import io.zulia.server.index.NodeRequestBase;
import io.zulia.server.index.ZuliaIndex;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public abstract class NodeRequestRouter extends NodeRequestBase {

	private Node node;

	public NodeRequestRouter(Node thisNode, Collection otherNodesActive, MasterSlaveSettings masterSlaveSettings, ZuliaIndex index, String uniqueId)
			throws IOException {

		super(thisNode, otherNodesActive);

		List nodeList = new ArrayList<>();
		nodeList.add(thisNode);
		nodeList.addAll(otherNodesActive);

		this.node = new MasterSlaveSelector(masterSlaveSettings, nodeList, index.getIndexMapping()).getNodeForUniqueId(uniqueId);

	}

	public O send(final I request) throws Exception {
		if (nodeIsLocal(node)) {
			return processInternal(node, request);
		}
		return processExternal(node, request);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy