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


Java DeviceAllocationInformation类代码示例

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


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

示例1: releaseDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
public void releaseDevice(DeviceAllocationInformation allocatedDeviceDescriptor)
    throws InvalidPasskeyException,
        DeviceNotFoundException {
    String deviceId = allocatedDeviceDescriptor.getDeviceId();
    long currentPasskey = allocatedDeviceDescriptor.getProxyPasskey();

    PasskeyAuthority.validatePasskey(currentPasskey, deviceId);

    try {
        IDevice device = devicePoolDao.getDevice(deviceId);

        if (device != null) {
            releaseDevice(device, currentPasskey);
        }
    } catch (DevicePoolDaoException e) {
        String errorMessage = String.format("Failed to release device with ID %s.", deviceId);
        LOGGER.fatal(errorMessage);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:20,代码来源:PoolManager.java

示例2: sendGetDeviceAllocationInfoRequest

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
/**
 * Allocates a device and send back a message with the {@link DeviceAllocationInformation} to the Client.
 *
 * @param getDeviceAllocationInformationRequest
 *        - {@link RequestMessage request message}
 * @param clientSession
 *        - the client's {@link Session session}
 */
void sendGetDeviceAllocationInfoRequest(RequestMessage getDeviceAllocationInformationRequest,
                                        Session clientSession) {

    DeviceSelector deviceSelector = (DeviceSelector) getDeviceAllocationInformationRequest.getArguments()[0];

    try {
        DeviceAllocationInformation deviceAllocationInformation = allocationManager.allocateDevice(deviceSelector,
                                                                                                   clientSession.getId(),
                                                                                                   WAIT_FOR_DEVICE_TIMEOUT);
        ResponseMessage response = new ResponseMessage(MessageAction.DEVICE_ALLOCATION_INFORMATION,
                                                       deviceAllocationInformation);
        response.setSessionId(getDeviceAllocationInformationRequest.getSessionId());

        sendText(jsonUtil.serialize(response), clientSession);
    } catch (NoDeviceMatchingTheGivenSelectorException | NoAvailableDeviceFoundException ex) {
        sendErrorResponseMessage(ex, clientSession, getDeviceAllocationInformationRequest.getSessionId());
        LOGGER.error(ex);
    }

}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:29,代码来源:ServerDispatcher.java

示例3: releaseDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
/**
 * Releases an allocated device. Removes all cached sessions associated to the device.
 *
 * @param deviceDescriptor
 *        - the {@link DeviceAllocationInformation} corresponding to the device which should be released
 */
void releaseDevice(RequestMessage requestMessage, Session session) {
    DeviceAllocationInformation deviceDescriptor = (DeviceAllocationInformation) requestMessage.getArguments()[0];

    String deviceId = deviceDescriptor.getDeviceId();
    removeCachedSessionByDeviceId(deviceId);

    try {
        poolManager.releaseDevice(deviceDescriptor);
        ResponseMessage releseResponse = new ResponseMessage(MessageAction.RELEASE_DEVICE, null, null);
        releseResponse.setSessionId(requestMessage.getSessionId());

        sendText(jsonUtil.serialize(releseResponse), session);
    } catch (InvalidPasskeyException | DeviceNotFoundException ex) {
        sendErrorResponseMessage(ex, session, requestMessage.getSessionId());
        LOGGER.error("Failed to release a device with id " + deviceId, ex);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:24,代码来源:ServerDispatcher.java

示例4: getPresentDeviceFirstTestTwo

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceFirstTestTwo() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_PREFERRED)
                                                                       .screenHeight(600)
                                                                       .screenWidth(800);
    DeviceSelector deviceSelector = selectorBuilder.build();

    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(firstDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(firstDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FIRST_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例5: getPresentDeviceFirstTestThree

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceFirstTestThree() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().ramCapacity(128);
    DeviceSelector deviceSelector = selectorBuilder.build();

    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(firstDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(firstDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FIRST_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:17,代码来源:PoolManagerDeviceSelectionTest.java

示例6: getPresentDeviceSecond

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceSecond() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().screenDpi(240);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(secondDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(secondDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(secondDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(SECOND_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:18,代码来源:PoolManagerDeviceSelectionTest.java

示例7: getPresentDeviceThird

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceThird() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().ramCapacity(512)
                                                                       .deviceType(DeviceType.DEVICE_ONLY);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(thirdDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(thirdDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(thirdDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(THIRD_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例8: getPresentDeviceFourth

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceFourth() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_ONLY)
                                                                       .screenDpi(180);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(fourthDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(fourthDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(fourthDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FOURTH_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例9: getPresentDeviceWithCamera

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceWithCamera() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.EMULATOR_ONLY)
                                                                       .isCameraAvailable(true);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(fourthDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(fourthDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(fourthDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FOURTH_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:19,代码来源:PoolManagerDeviceSelectionTest.java

示例10: getPresentDeviceWithoutCamera

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceWithoutCamera() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().isCameraAvailable(false);
    DeviceSelector deviceSelector = selectorBuilder.build();

    List<IDevice> deviceList = Arrays.asList(fifthDevice);
    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(fifthDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(fifthDevice);

    poolManager.releaseDevice(deviceId);

    assertCorrectDeviceFetched(FIFTH_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:18,代码来源:PoolManagerDeviceSelectionTest.java

示例11: checkClients

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
/**
 * Checks whether a client {@link DeviceSelector selector} is applicable to the newly available device(published or
 * released).
 *
 * @param deviceInformation
 *        - information about the {@link IDevice device}
 */
private void checkClients(DeviceInformation deviceInformation) {
    synchronized (waitingClients) {
        availableDeviceLatch = new CountDownLatch(COUNTDOWN_NUMBER);

        ListIterator<Pair<DeviceSelector, String>> li = waitingClients.listIterator(waitingClients.size());
        while (li.hasPrevious()) {
            Pair<DeviceSelector, String> clientInfo = li.previous();
            DeviceSelector deviceSelector = clientInfo.getKey();
            String clientId = clientInfo.getValue();

            boolean isApplicable = slectorResolver.isApplicable(deviceSelector, deviceInformation);

            if (isApplicable) {
                DeviceAllocationInformation dAlloc = allocate(deviceSelector);

                if (dAlloc != null) {
                    li.remove();
                    clientIdForDeviceAllocationInformation.put(clientId, dAlloc);
                    clientIdForLatch.get(clientId).countDown();
                    break;
                }
            }
        }

        availableDeviceLatch.countDown();
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:35,代码来源:DeviceAllocationManager.java

示例12: getPresentDeviceFirstTestOne

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
@Test
public void getPresentDeviceFirstTestOne() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().ramCapacity(128);
    DeviceSelector deviceSelector = selectorBuilder.build();

    when(devicePoolDao.getDevices(eq(deviceSelector), eq(false))).thenReturn(deviceList);
    DeviceAllocationInformation deviceDescriptor = poolManager.allocateDevice(deviceSelector);
    String deviceId = deviceDescriptor.getDeviceId();

    doNothing().when(devicePoolDao).update(firstDevice);
    when(devicePoolDao.getDevice(eq(deviceId))).thenReturn(firstDevice);

    poolManager.releaseDevice(deviceId);
    assertCorrectDeviceFetched(FIRST_DEVICE_SERIAL_NUMBER, deviceDescriptor);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:16,代码来源:PoolManagerDeviceSelectionTest.java

示例13: assertCorrectDeviceFetched

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
private void assertCorrectDeviceFetched(String expectedDeviceSerialNumber,
                                        DeviceAllocationInformation allocatedDeviceInformation) {
    String deviceId = allocatedDeviceInformation.getDeviceId();
    assertEquals("Failed to receive the ID of the correct device.",
                 String.format(DEVICE_ID_FORMAT, expectedDeviceSerialNumber),
                 deviceId);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-server,代码行数:8,代码来源:PoolManagerDeviceSelectionTest.java

示例14: getDeviceDescriptor

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
/**
 *
 * Gets a {@link DeviceAllocationInformation} instance with the given {@link DeviceSelector device characteristics}.
 *
 * @param deviceSelector
 *        - required {@link DeviceSelector parameters} needed to construct new {@link DeviceAllocationInformation}
 *        instance.
 * @param allocateDeviceRetryCount
 *        - the number of the attempts to get a device
 * @return a {@link DeviceAllocationInformation} instance with the given device selector.
 * @throws NoAvailableDeviceFoundException
 *         - when there is no available device
 */
public DeviceAllocationInformation getDeviceDescriptor(DeviceSelector deviceSelector,
                                                       int allocateDeviceRetryCount) {
    RequestMessage request = new RequestMessage(MessageAction.DEVICE_ALLOCATION_INFORMATION, deviceSelector);
    ResponseMessage response = sendRequest(request, session, WAIT_FOR_DEVICE_TIME);
    if (response.getMessageAction() != MessageAction.ERROR) {
        return (DeviceAllocationInformation) response.getData();
    }

    if (response.getException() instanceof NoDeviceMatchingTheGivenSelectorException) {
        throw (NoDeviceMatchingTheGivenSelectorException) response.getException();
    }

    throw new NoAvailableDeviceFoundException();
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:28,代码来源:ClientDispatcher.java

示例15: releaseDevice

import com.musala.atmosphere.commons.cs.clientbuilder.DeviceAllocationInformation; //导入依赖的package包/类
/**
 * Sends a release device request to the Server and receives a response.
 *
 * @param deviceInformation
 *        - describes a device that will be released
 * @throws Exception
 *         - when an error occurred when trying to release a device
 */
public void releaseDevice(DeviceAllocationInformation deviceInformation) throws Exception {
    RequestMessage releaseDeviceRequest = new RequestMessage(MessageAction.RELEASE_DEVICE, deviceInformation);

    ResponseMessage response = sendRequest(releaseDeviceRequest, session);
    if (response != null && response.getException() != null) {
        LOGGER.error("An error occurred when trying to release a device.", response.getException());
        throw response.getException();
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-client,代码行数:18,代码来源:ClientDispatcher.java


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