Search in sources :

Example 1 with XSiteAutoTransferStatusCommand

use of org.infinispan.xsite.commands.XSiteAutoTransferStatusCommand in project infinispan by infinispan.

the class XSiteAutoStateTransferTest method testSingleManualModeDoNotTriggerStateTransfer.

public void testSingleManualModeDoNotTriggerStateTransfer() throws InterruptedException, TimeoutException, ExecutionException {
    // site1 is the async one
    String remoteSite = siteName(1);
    // make the remote site offline.
    for (int i = 0; i < defaultNumberOfNodes(); ++i) {
        TakeOfflineManager manager = takeOfflineManager(i);
        assertNotSame(TakeSiteOfflineResponse.NO_SUCH_SITE, manager.takeSiteOffline(remoteSite));
        assertSame(SiteState.OFFLINE, manager.getSiteState(remoteSite));
    }
    SiteMasterController controller = findSiteMaster();
    boolean manualModeSet = false;
    for (int i = 0; i < defaultNumberOfNodes(); ++i) {
        if (i == controller.managerIndex) {
            stateTransferManager(i).setAutomaticStateTransfer(remoteSite, XSiteStateTransferMode.AUTO);
        } else if (!manualModeSet) {
            stateTransferManager(i).setAutomaticStateTransfer(remoteSite, XSiteStateTransferMode.MANUAL);
            manualModeSet = true;
        }
    // else, does not mather if the 3rd node is MANUAL or AUTO since it shouldn't start any state transfer if at least one node is MANUAL
    }
    // block sites up event and wait until received
    SiteUpEvent event = controller.getStateTransferManager().blockSiteUpEvent();
    triggerSiteUpEvent(controller, remoteSite);
    Collection<String> sitesUp = event.waitForEvent();
    // check if it is the correct event
    assertEquals(1, sitesUp.size());
    assertEquals(remoteSite, sitesUp.iterator().next());
    CompletableFuture<ControlledRpcManager.BlockedRequest<XSiteAutoTransferStatusCommand>> req = controller.getRpcManager().expectCommandAsync(XSiteAutoTransferStatusCommand.class);
    // let the event continue, it will be handled in this thread, which is fine
    event.continueRunnable();
    // we expect the coordinator to send a command
    ControlledRpcManager.BlockedRequest<XSiteAutoTransferStatusCommand> cmd = req.get(30, TimeUnit.SECONDS);
    cmd.send().receiveAll();
    // site status must not change
    for (int i = 0; i < defaultNumberOfNodes(); ++i) {
        TakeOfflineManager manager = takeOfflineManager(i);
        assertSame(SiteState.OFFLINE, manager.getSiteState(remoteSite));
    }
}
Also used : TakeOfflineManager(org.infinispan.xsite.status.TakeOfflineManager) ControlledRpcManager(org.infinispan.util.ControlledRpcManager) XSiteAutoTransferStatusCommand(org.infinispan.xsite.commands.XSiteAutoTransferStatusCommand)

Example 2 with XSiteAutoTransferStatusCommand

use of org.infinispan.xsite.commands.XSiteAutoTransferStatusCommand in project infinispan by infinispan.

the class XSiteStateTransferManagerImpl method isStateTransferRequired.

private CompletionStage<Boolean> isStateTransferRequired(RemoteSiteStatus status) {
    final String site = status.getSiteName();
    AutoStateTransferResponseCollector collector = new AutoStateTransferResponseCollector(takeOfflineManager.getSiteState(site) == SiteState.OFFLINE, status.stateTransferMode());
    XSiteAutoTransferStatusCommand cmd = commandsFactory.buildXSiteAutoTransferStatusCommand(site);
    return rpcManager.invokeCommandOnAll(cmd, collector, rpcManager.getSyncRpcOptions()).thenApply(AutoStateTransferResponse::canDoAutomaticStateTransfer);
}
Also used : AutoStateTransferResponseCollector(org.infinispan.xsite.response.AutoStateTransferResponseCollector) AutoStateTransferResponse(org.infinispan.xsite.response.AutoStateTransferResponse) XSiteAutoTransferStatusCommand(org.infinispan.xsite.commands.XSiteAutoTransferStatusCommand)

Aggregations

XSiteAutoTransferStatusCommand (org.infinispan.xsite.commands.XSiteAutoTransferStatusCommand)2 ControlledRpcManager (org.infinispan.util.ControlledRpcManager)1 AutoStateTransferResponse (org.infinispan.xsite.response.AutoStateTransferResponse)1 AutoStateTransferResponseCollector (org.infinispan.xsite.response.AutoStateTransferResponseCollector)1 TakeOfflineManager (org.infinispan.xsite.status.TakeOfflineManager)1