Package com.opengamma.engine.view.client

Examples of com.opengamma.engine.view.client.ViewClient


  @Path("{viewId}/pauseOrResume")
  @PUT
  public Response pauseOrResumeView(@PathParam("viewId") String viewId,
                                    @FormParam("state") String state) {
    ViewClient viewClient = _viewManager.getViewCient(viewId);
    state = StringUtils.stripToNull(state);
    Response response = Response.status(Response.Status.BAD_REQUEST).build();
    if (state != null) {
      ViewClientState currentState = viewClient.getState();
      state = state.toUpperCase();
      switch (state) {
        case "PAUSE":
        case "P":
          if (currentState != ViewClientState.TERMINATED) {
            viewClient.pause();
            response = Response.ok().build();
          }
          break;
        case "RESUME":
        case "R":
          if (currentState != ViewClientState.TERMINATED) {
            viewClient.resume();
            response = Response.ok().build();
          }
          break;
        default:
          s_logger.warn("client {} requesting for invalid view client state change to {}", viewId, state);
View Full Code Here


        // Existing view is different - client is switching views
        shutDownWebView(webView);
        _clientViews.remove(remote.getId());
      }

      ViewClient viewClient = getViewProcessor().createViewClient(user);
      try {
        UniqueId viewDefinitionId = _aggregatedViewDefinitionManager.getViewDefinitionId(baseViewDefinitionId, aggregatorName);
        webView = new WebView(getLocalSession(), remote, viewClient, baseViewDefinitionId, aggregatorName, viewDefinitionId,
            executionOptions, user, getExecutorService(), getResultConverterCache(), getComputationTargetResolver());
      } catch (Exception e) {
        _aggregatedViewDefinitionManager.releaseViewDefinition(baseViewDefinitionId, aggregatorName);
        viewClient.shutdown();
        throw new OpenGammaRuntimeException("Error attaching client to view definition '" + baseViewDefinitionId + "'", e);
      }
      _clientViews.put(remote.getId(), webView);
    }
  }
View Full Code Here

    final UniqueId viewClientId = UniqueId.parse(viewClientIdString);
    final DataViewClientResource viewClientResource = _createdViewClients.get(viewClientId);
    if (viewClientResource != null) {
      return viewClientResource;
    }
    final ViewClient viewClient = getViewProcessor().getViewClient(viewClientId);
    final URI viewProcessorUri = getViewProcessorUri(uriInfo);
    return createViewClientResource(viewClient, viewProcessorUri);
  }
View Full Code Here

  @POST
  @Path(PATH_CLIENTS)
  @Consumes(FudgeRest.MEDIA)
  public Response createViewClient(@Context final UriInfo uriInfo, final UserPrincipal user) {
    final ViewClient client = getViewProcessor().createViewClient(user);
    final URI viewProcessorUri = getViewProcessorUri(uriInfo);
    // Required for heartbeating, but also acts as an optimisation for getViewClient because view clients created
    // through the REST API should be accessed again through the same API, potentially many times.
    final DataViewClientResource viewClientResource = createViewClientResource(client, viewProcessorUri);
    _createdViewClients.put(client.getUniqueId(), viewClientResource);
    final URI createdUri = uriClient(uriInfo.getRequestUri(), client.getUniqueId());
    return responseCreated(createdUri);
  }
View Full Code Here

                                              versionCorrection,
                                              _positionSource,
                                              _securitySource,
                                              _portfolioResolutionExecutor);
    // TODO something a bit more sophisticated with the executor
    ViewClient viewClient = _viewProcessor.createViewClient(user);
    s_logger.debug("Client ID {} creating new view with ID {}", clientId, viewId);
    ViewportListener viewportListener = new LoggingViewportListener(viewClient);
    PortfolioEntityExtractor entityExtractor = new PortfolioEntityExtractor(versionCorrection, _securityMaster);
    // TODO add filtering change listener to portfolio master which calls portfolioChanged() on the outer view
    boolean primitivesOnly = portfolioId == null;
View Full Code Here

   */
  public void removeViewClient(final UniqueId clientId) {
    ArgumentChecker.notNull(clientId, "clientId");
    checkIdScheme(clientId, CLIENT_SCHEME);
    s_logger.info("Removing view client {}", clientId);
    final ViewClient client = _allClientsById.remove(clientId);
    if (client == null) {
      throw new DataNotFoundException("View client not found: " + clientId);
    }
    detachClientFromViewProcess(clientId);
    _viewProcessorEventListenerRegistry.notifyViewClientRemoved(clientId);
View Full Code Here

    _calcConfigByViewProcessId.remove(viewProcessId);
  }

  @Override
  public void notifyViewClientAdded(UniqueId viewClientId) {
    ViewClient viewClient = _viewProcessor.getViewClient(viewClientId);
    ViewClientMBeanImpl viewClientBean = new ViewClientMBeanImpl(viewClient);
    try {
      registerViewClient(viewClientBean);
    } catch (Exception e) {
      s_logger.warn("Error registering view client for management for " + viewClientBean.getObjectName() + ". Error was " + e.getMessage(), e);
View Full Code Here

  public void testRegistrationServiceListenersForViewClientAdded() throws Exception {
    ViewProcessorImpl viewProcessor = _env.getViewProcessor();
    viewProcessor.start();
    ManagementService.registerMBeans(viewProcessor, _statisticsProvider, _mBeanServer);
    assertMBeanCount(MBEANS_IN_TEST_VIEWPROCESSOR);
    ViewClient client1 = viewProcessor.createViewClient(UserPrincipal.getTestUser());
    assertMBeanCount(MBEANS_IN_TEST_VIEWPROCESSOR + 1);
    ViewClient client2 = viewProcessor.createViewClient(UserPrincipal.getTestUser());
    assertMBeanCount(MBEANS_IN_TEST_VIEWPROCESSOR + 2);
    client1.shutdown();
    assertMBeanCount(MBEANS_IN_TEST_VIEWPROCESSOR + 1);
    client2.shutdown();
    assertMBeanCount(MBEANS_IN_TEST_VIEWPROCESSOR);
  }
View Full Code Here

  private void addAnotherView(ViewProcessorImpl viewprocessor) {
    ViewDefinition anotherDefinition = new ViewDefinition(UniqueId.of("boo", "far"), ANOTHER_TEST_VIEW, ViewProcessorTestEnvironment.TEST_USER);
    anotherDefinition.addViewCalculationConfiguration(_env.getViewDefinition().getCalculationConfiguration(ViewProcessorTestEnvironment.TEST_CALC_CONFIG_NAME));
    _env.getMockViewDefinitionRepository().put(anotherDefinition);
    ViewClient client = viewprocessor.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    client.attachToViewProcess(anotherDefinition.getUniqueId(), ExecutionOptions.infinite(MarketData.live()), false);
  }
View Full Code Here

    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    env.init();
    final ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();

    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    final TestViewResultListener resultListener = new TestViewResultListener();
    client.setResultListener(resultListener);
    client.attachToViewProcess(UniqueId.of("not", "here"), ExecutionOptions.infinite(MarketData.live(), ExecutionFlags.none().get()));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.client.ViewClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.