当前位置: 首页>>代码示例>>Java>>正文


Java Answer类代码示例

本文整理汇总了Java中com.cloud.agent.api.Answer的典型用法代码示例。如果您正苦于以下问题:Java Answer类的具体用法?Java Answer怎么用?Java Answer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Answer类属于com.cloud.agent.api包,在下文中一共展示了Answer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleStorageCommands

import com.cloud.agent.api.Answer; //导入依赖的package包/类
public Answer handleStorageCommands(final StorageSubSystemCommand command) {
    if (command instanceof CopyCommand) {
        return this.execute((CopyCommand) command);
    } else if (command instanceof AttachPrimaryDataStoreCmd) {
        return this.execute((AttachPrimaryDataStoreCmd) command);
    } else if (command instanceof CreatePrimaryDataStoreCmd) {
        return execute((CreatePrimaryDataStoreCmd) command);
    } else if (command instanceof CreateObjectCommand) {
        return execute((CreateObjectCommand) command);
    } else if (command instanceof DeleteCommand) {
        return execute((DeleteCommand) command);
    } else if (command instanceof AttachCommand) {
        return execute((AttachCommand) command);
    } else if (command instanceof DettachCommand) {
        return execute((DettachCommand) command);
    }
    return new Answer(command, false, "not implemented yet");
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:19,代码来源:KvmStorageResource.java

示例2: execute

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Override
public Answer execute(final FindLogicalSwitchPortCommand command, final NiciraNvpResource niciraNvpResource) {
    final String logicalSwitchUuid = command.getLogicalSwitchUuid();
    final String logicalSwitchPortUuid = command.getLogicalSwitchPortUuid();

    final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();

    try {
        final List<LogicalSwitchPort> ports = niciraNvpApi.findLogicalSwitchPortsByUuid(logicalSwitchUuid, logicalSwitchPortUuid);
        if (ports.size() == 0) {
            return new FindLogicalSwitchPortAnswer(command, false, "Logical switchport " + logicalSwitchPortUuid + " not found", null);
        } else {
            return new FindLogicalSwitchPortAnswer(command, true, "Logical switchport " + logicalSwitchPortUuid + " found", logicalSwitchPortUuid);
        }
    } catch (final NiciraNvpApiException e) {
        final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
        retryUtility.addRetry(command, NUM_RETRIES);
        return retryUtility.retry(command, FindLogicalSwitchPortAnswer.class, e);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:21,代码来源:NiciraNvpFindLogicalSwitchPortCommandWrapper.java

示例3: sendTo

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Override
public Answer sendTo(final Long dcId, final HypervisorType type, final Command cmd) {
    final List<ClusterVO> clusters = _clusterDao.listByDcHyType(dcId, type.toString());
    int retry = 0;
    for (final ClusterVO cluster : clusters) {
        final List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), null, dcId);
        for (final HostVO host : hosts) {
            retry++;
            if (retry > _retry) {
                return null;
            }
            Answer answer = null;
            try {

                final long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(host.getId(), cmd);
                answer = easySend(targetHostId, cmd);
            } catch (final Exception e) {
            }
            if (answer != null) {
                return answer;
            }
        }
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:26,代码来源:AgentManagerImpl.java

示例4: attachIso

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Override
public Answer attachIso(final AttachCommand cmd) {
    final DiskTO disk = cmd.getDisk();
    final TemplateObjectTO isoTo = (TemplateObjectTO) disk.getData();
    final DataStoreTO store = isoTo.getDataStore();
    if (!(store instanceof NfsTO)) {
        return new AttachAnswer("unsupported protocol");
    }
    final NfsTO nfsStore = (NfsTO) store;
    try {
        final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
        attachOrDetachIso(conn, cmd.getVmName(), nfsStore.getUrl() + File.separator + isoTo.getPath(), true);
    } catch (final LibvirtException | URISyntaxException | InternalErrorException e) {
        return new Answer(cmd, false, e.toString());
    }

    return new Answer(cmd);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:19,代码来源:KvmStorageProcessor.java

示例5: propagateAgentEvent

import com.cloud.agent.api.Answer; //导入依赖的package包/类
public Boolean propagateAgentEvent(final long agentId, final Event event) throws AgentUnavailableException {
    final String msPeer = getPeerName(agentId);
    if (msPeer == null) {
        return null;
    }

    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId);
    }
    final Command[] cmds = new Command[1];
    cmds[0] = new ChangeAgentCommand(agentId, event);

    final String ansStr = _clusterMgr.execute(msPeer, agentId, _gson.toJson(cmds), true);
    if (ansStr == null) {
        throw new AgentUnavailableException(agentId);
    }

    final Answer[] answers = _gson.fromJson(ansStr, Answer[].class);

    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Result for agent change is " + answers[0].getResult());
    }

    return answers[0].getResult();
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:26,代码来源:ClusteredAgentManagerImpl.java

示例6: sendRebalanceCommand

import com.cloud.agent.api.Answer; //导入依赖的package包/类
private Answer[] sendRebalanceCommand(final long peer, final long agentId, final long currentOwnerId, final long futureOwnerId, final Event event) {
    final TransferAgentCommand transfer = new TransferAgentCommand(agentId, currentOwnerId, futureOwnerId, event);
    final Commands commands = new Commands(Command.OnError.Stop);
    commands.addCommand(transfer);

    final Command[] cmds = commands.toCommands();

    try {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Forwarding " + cmds[0].toString() + " to " + peer);
        }
        final String peerName = Long.toString(peer);
        final String cmdStr = _gson.toJson(cmds);
        final String ansStr = _clusterMgr.execute(peerName, agentId, cmdStr, true);
        final Answer[] answers = _gson.fromJson(ansStr, Answer[].class);
        return answers;
    } catch (final Exception e) {
        s_logger.warn("Caught exception while talking to " + currentOwnerId, e);
        return null;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:22,代码来源:ClusteredAgentManagerImpl.java

示例7: handleScheduleHostScanTaskCommand

import com.cloud.agent.api.Answer; //导入依赖的package包/类
private String handleScheduleHostScanTaskCommand(final ScheduleHostScanTaskCommand cmd) {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Intercepting resource manager command: " + _gson.toJson(cmd));
    }

    try {
        scheduleHostScanTask();
    } catch (final Exception e) {
        // Scheduling host scan task in peer MS is a best effort operation during host add, regular host scan
        // happens at fixed intervals anyways. So handling any exceptions that may be thrown
        s_logger.warn("Exception happened while trying to schedule host scan task on mgmt server " + _clusterMgr.getSelfPeerName() +
                ", ignoring as regular host scan happens at fixed interval anyways", e);
        return null;
    }

    final Answer[] answers = new Answer[1];
    answers[0] = new Answer(cmd, true, null);
    return _gson.toJson(answers);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:20,代码来源:ClusteredAgentManagerImpl.java

示例8: testModifyStoragePoolCommand

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Test
public void testModifyStoragePoolCommand() {
    final StoragePoolVO poolVO = Mockito.mock(StoragePoolVO.class);
    final XsHost xsHost = Mockito.mock(XsHost.class);

    final ModifyStoragePoolCommand modifyStorageCommand = new ModifyStoragePoolCommand(false, poolVO);

    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);

    when(citrixResourceBase.getHost()).thenReturn(xsHost);

    final Answer answer = wrapper.execute(modifyStorageCommand, citrixResourceBase);
    verify(citrixResourceBase, times(1)).getConnection();

    assertFalse(answer.getResult());
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:18,代码来源:CitrixRequestWrapperTest.java

示例9: execute

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Override
public Answer execute(final PingTestCommand command, final LibvirtComputingResource libvirtComputingResource) {
    String result = null;
    final String computingHostIp = command.getComputingHostIp(); // TODO, split the command into 2 types

    if (computingHostIp != null) {
        result = doPingTest(libvirtComputingResource, computingHostIp);
    } else if (command.getRouterIp() != null && command.getPrivateIp() != null) {
        result = doPingTest(libvirtComputingResource, command.getRouterIp(), command.getPrivateIp());
    } else {
        return new Answer(command, false, "routerip and private ip is null");
    }

    if (result != null) {
        return new Answer(command, false, result);
    }
    return new Answer(command);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:19,代码来源:LibvirtPingTestCommandWrapper.java

示例10: testCleanupNetworkRulesCmd

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Test
public void testCleanupNetworkRulesCmd() {
    final Connection conn = Mockito.mock(Connection.class);
    final XsHost xsHost = Mockito.mock(XsHost.class);

    final CleanupNetworkRulesCmd cleanupNets = new CleanupNetworkRulesCmd(20);

    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);

    when(citrixResourceBase.canBridgeFirewall()).thenReturn(true);
    when(citrixResourceBase.getConnection()).thenReturn(conn);
    when(citrixResourceBase.getHost()).thenReturn(xsHost);
    when(citrixResourceBase.getVMInstanceName()).thenReturn("VM");
    when(citrixResourceBase.callHostPlugin(conn, "vmops", "cleanup_rules", "instance", citrixResourceBase.getVMInstanceName())).thenReturn("1");

    final Answer answer = wrapper.execute(cleanupNets, citrixResourceBase);

    verify(citrixResourceBase, times(1)).getConnection();

    assertTrue(answer.getResult());
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:23,代码来源:CitrixRequestWrapperTest.java

示例11: testDeleteLogicalRouterCommand

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Test
public void testDeleteLogicalRouterCommand() {
    final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);

    final String logicalRouterUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";

    final DeleteLogicalRouterCommand command = new DeleteLogicalRouterCommand(logicalRouterUuid);

    when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);

    try {
        doNothing().when(niciraNvpApi).deleteLogicalRouter(command.getLogicalRouterUuid());
    } catch (final NiciraNvpApiException e) {
        fail(e.getMessage());
    }

    final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
    assertNotNull(wrapper);

    final Answer answer = wrapper.execute(command, niciraNvpResource);

    assertTrue(answer.getResult());
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:24,代码来源:NiciraNvpRequestWrapperTest.java

示例12: testNetworkUsageCommandVpcNoOption

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Test
public void testNetworkUsageCommandVpcNoOption() {
    final String privateIP = "127.0.0.1";
    final String domRName = "domR";
    final boolean forVpc = true;
    final String gatewayIP = "127.0.0.1";

    final NetworkUsageCommand command = new NetworkUsageCommand(privateIP, domRName, null, forVpc, gatewayIP);

    libvirtComputingResource.getNetworkStats(command.getPrivateIP());

    when(libvirtComputingResource.configureVpcNetworkUsage(command.getPrivateIP(), command.getGatewayIP(),
            command.getOption(), command.getVpcCIDR())).thenReturn("FAILURE");

    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);

    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());

    verify(libvirtComputingResource, times(1)).configureVpcNetworkUsage(command.getPrivateIP(), command.getGatewayIP(),
            command.getOption(), command.getVpcCIDR());
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:24,代码来源:LibvirtComputingResourceTest.java

示例13: doUpdateHostPassword

import com.cloud.agent.api.Answer; //导入依赖的package包/类
private boolean doUpdateHostPassword(final long hostId) {
    if (!_agentMgr.isAgentAttached(hostId)) {
        return false;
    }

    DetailVO nv = _hostDetailsDao.findDetail(hostId, ApiConstants.USERNAME);
    final String username = nv.getValue();
    nv = _hostDetailsDao.findDetail(hostId, ApiConstants.PASSWORD);
    final String password = nv.getValue();

    final HostVO host = _hostDao.findById(hostId);
    final String hostIpAddress = host.getPrivateIpAddress();

    final UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password, hostIpAddress);
    final Answer answer = _agentMgr.easySend(hostId, cmd);

    s_logger.info("Result returned from update host password ==> " + answer.getDetails());
    return answer.getResult();
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:20,代码来源:ResourceManagerImpl.java

示例14: testCheckSshCommand

import com.cloud.agent.api.Answer; //导入依赖的package包/类
@Test
public void testCheckSshCommand() {
    final String instanceName = "Test";
    final String ip = "127.0.0.1";
    final int port = 22;

    final CheckSshCommand command = new CheckSshCommand(instanceName, ip, port);

    final VirtualRoutingResource virtRouterResource = Mockito.mock(VirtualRoutingResource.class);

    final String privateIp = command.getIp();
    final int cmdPort = command.getPort();

    when(libvirtComputingResource.getVirtRouterResource()).thenReturn(virtRouterResource);
    when(virtRouterResource.connect(privateIp, cmdPort)).thenReturn(true);

    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);

    final Answer answer = wrapper.execute(command, libvirtComputingResource);
    assertTrue(answer.getResult());

    verify(libvirtComputingResource, times(1)).getVirtRouterResource();
    verify(virtRouterResource, times(1)).connect(privateIp, cmdPort);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:26,代码来源:LibvirtComputingResourceTest.java

示例15: retry

import com.cloud.agent.api.Answer; //导入依赖的package包/类
public Answer retry(final Command command, final Class<? extends Answer> answerClass, final Exception error) {
    if (commandsToRetry.containsKey(command)) {
        Integer numRetries = commandsToRetry.get(command);

        if (numRetries > ZERO) {
            commandsToRetry.put(command, --numRetries);

            s_logger.warn("Retrying " + command.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries);

            return serverResource.executeRequest(command);
        } else {
            commandsToRetry.remove(command);
        }
    }
    try {
        final Constructor<? extends Answer> answerConstructor = answerClass.getConstructor(Command.class, Exception.class);
        return answerConstructor.newInstance(command, error);
    } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        return Answer.createUnsupportedCommandAnswer(command);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:22,代码来源:CommandRetryUtility.java


注:本文中的com.cloud.agent.api.Answer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。