Search in sources :

Example 6 with CseServer

use of org.apache.servicecomb.loadbalance.CseServer in project incubator-servicecomb-java-chassis by apache.

the class SimpleTransactionControlFilter method getFilteredListOfServers.

@Override
public List<Server> getFilteredListOfServers(List<Server> servers) {
    List<Server> filteredServers = new ArrayList<>();
    Map<String, String> filterOptions = Configuration.INSTANCE.getFlowsplitFilterOptions(getInvocation().getMicroserviceName());
    for (Server server : servers) {
        if (allowVisit((CseServer) server, filterOptions)) {
            filteredServers.add(server);
        }
    }
    return filteredServers;
}
Also used : CseServer(org.apache.servicecomb.loadbalance.CseServer) Server(com.netflix.loadbalancer.Server) ArrayList(java.util.ArrayList)

Example 7 with CseServer

use of org.apache.servicecomb.loadbalance.CseServer in project incubator-servicecomb-java-chassis by apache.

the class TestCseServerDiscoveryFilter method createEndpoint_TransportNotExist.

@Test
public void createEndpoint_TransportNotExist() {
    new Expectations() {

        {
            transportManager.findTransport(anyString);
            result = null;
        }
    };
    CseServer server = (CseServer) filter.createEndpoint(Const.RESTFUL, null, null);
    Assert.assertNull(server);
}
Also used : Expectations(mockit.Expectations) CseServer(org.apache.servicecomb.loadbalance.CseServer) Test(org.junit.Test)

Example 8 with CseServer

use of org.apache.servicecomb.loadbalance.CseServer in project incubator-servicecomb-java-chassis by apache.

the class TestCseServerDiscoveryFilter method createEndpointNormal.

@Test
public void createEndpointNormal() {
    new Expectations() {

        {
            transportManager.findTransport(anyString);
            result = trasport;
        }
    };
    MicroserviceInstance instance = new MicroserviceInstance();
    CseServer server = (CseServer) filter.createEndpoint(Const.RESTFUL, "rest://localhost:8080", instance);
    Assert.assertSame(instance, server.getInstance());
    Assert.assertSame(trasport, server.getEndpoint().getTransport());
    Assert.assertEquals("rest://localhost:8080", server.getEndpoint().getEndpoint());
}
Also used : Expectations(mockit.Expectations) CseServer(org.apache.servicecomb.loadbalance.CseServer) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Aggregations

CseServer (org.apache.servicecomb.loadbalance.CseServer)8 Server (com.netflix.loadbalancer.Server)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Expectations (mockit.Expectations)3 Invocation (org.apache.servicecomb.core.Invocation)3 MicroserviceInstance (org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)3 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)2 Mock (mockit.Mock)1 DataCenterInfo (org.apache.servicecomb.serviceregistry.api.registry.DataCenterInfo)1