Examples of MonitorService


Examples of org.apache.directmemory.measures.MonitorService

{

    private void testSerializer( String name, Serializer serializer, int size, int howMany )
        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        MonitorService stopWatch = Monitor.get( "serializer." + name + "." + size + "bytes" );
        MonitorService stopWatch2 = Monitor.get( "deserializer." + name + "." + size + "bytes" );
        DummyPojo pojo = new DummyPojo( "test", size );
        for ( int i = 0; i < howMany; i++ )
        {
            long split = stopWatch.start();
            final byte[] array = serializer.serialize( pojo );
            stopWatch.stop( split );
            long split2 = stopWatch2.start();
            DummyPojo check = serializer.deserialize( array, pojo.getClass() );
            stopWatch2.stop( split2 );
            assertNotNull( "object has not been serialized", check );
            assertEquals( pojo.name, check.name );
        }
    }
View Full Code Here

Examples of org.apache.directmemory.measures.MonitorService

    private void testSerializer( String name, Serializer serializer, int size, int howMany )
        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        logger.info( "begin " + serializer.getClass().toString() );
        MonitorService stopWatch = Monitor.get( "serializer." + name + "." + size + "bytes" );
        MonitorService stopWatch2 = Monitor.get( "deserializer." + name + "." + size + "bytes" );
        DummyPojo pojo = new DummyPojo( "test", size );
        for ( int i = 0; i < howMany; i++ )
        {
            long split = stopWatch.start();
            final byte[] array = serializer.serialize( pojo );
            stopWatch.stop( split );
            long split2 = stopWatch2.start();
            DummyPojo check = (DummyPojo) serializer.deserialize( array, pojo.getClass() );
            stopWatch2.stop( split2 );
            assertNotNull( "object has not been serialized", check );
            assertEquals( pojo.name, check.name );
        }
        logger.info( "end serialize " + serializer.getClass().toString() + "\r\n" + stopWatch.toString() );
        logger.info( "end deserialize " + serializer.getClass().toString() + "\r\n" + stopWatch2.toString() );
    }
View Full Code Here

Examples of org.apache.flume.instrumentation.MonitorService

    memChannel.stop();
    pmemChannel.stop();
  }

  private void testWithPort(int port) throws Exception {
    MonitorService srv = new HTTPMetricsServer();
    Context context = new Context();
    if(port > 1024){
      context.put(HTTPMetricsServer.CONFIG_PORT, String.valueOf(port));
    } else {
      port = HTTPMetricsServer.DEFAULT_PORT;
    }
    srv.configure(context);
    srv.start();
    Thread.sleep(1000);
    URL url = new URL("http://0.0.0.0:" + String.valueOf(port) + "/metrics");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(conn.getInputStream()));
    String line;
    String result = "";
    while ((line = reader.readLine()) != null) {
      result += line;
    }
    reader.close();
    Map<String, Map<String, String>> mbeans = gson.fromJson(result, mapType);
    Assert.assertNotNull(mbeans);
    Map<String, String> memBean = mbeans.get("CHANNEL.memChannel");
    Assert.assertNotNull(memBean);
    JMXTestUtils.checkChannelCounterParams(memBean);
    Map<String, String> pmemBean = mbeans.get("CHANNEL.pmemChannel");
    Assert.assertNotNull(pmemBean);
    JMXTestUtils.checkChannelCounterParams(pmemBean);
    srv.stop();
    System.out.println(String.valueOf(port) + "test success!");
  }
View Full Code Here

Examples of org.apache.flume.instrumentation.MonitorService

    doTestForbiddenMethods(4432,"OPTIONS");
  }

  public void doTestForbiddenMethods(int port, String method)
    throws Exception {
    MonitorService srv = new HTTPMetricsServer();
    Context context = new Context();
    if (port > 1024) {
      context.put(HTTPMetricsServer.CONFIG_PORT, String.valueOf(port));
    } else {
      port = HTTPMetricsServer.DEFAULT_PORT;
    }
    srv.configure(context);
    srv.start();
    Thread.sleep(1000);
    URL url = new URL("http://0.0.0.0:" + String.valueOf(port) + "/metrics");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod(method);
    Assert.assertEquals(HttpServletResponse.SC_FORBIDDEN,
      conn.getResponseCode());
    srv.stop();
  }
View Full Code Here

Examples of org.apache.flume.instrumentation.MonitorService

    memChannel.stop();
    pmemChannel.stop();
  }

  private void testWithPort(int port) throws Exception {
    MonitorService srv = new HTTPMetricsServer();
    Context context = new Context();
    if(port > 1024){
      context.put(HTTPMetricsServer.CONFIG_PORT, String.valueOf(port));
    } else {
      port = HTTPMetricsServer.DEFAULT_PORT;
    }
    srv.configure(context);
    srv.start();
    Thread.sleep(1000);
    URL url = new URL("http://0.0.0.0:" + String.valueOf(port) + "/metrics");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(conn.getInputStream()));
    String line;
    String result = "";
    while ((line = reader.readLine()) != null) {
      result += line;
    }
    reader.close();
    Map<String, Map<String, String>> mbeans = gson.fromJson(result, mapType);
    Assert.assertNotNull(mbeans);
    Map<String, String> memBean = mbeans.get("CHANNEL.memChannel");
    Assert.assertNotNull(memBean);
    JMXTestUtils.checkChannelCounterParams(memBean);
    Map<String, String> pmemBean = mbeans.get("CHANNEL.pmemChannel");
    Assert.assertNotNull(pmemBean);
    JMXTestUtils.checkChannelCounterParams(pmemBean);
    srv.stop();
    System.out.println(String.valueOf(port) + "test success!");
  }
View Full Code Here

Examples of org.g4studio.system.admin.service.MonitorService

      String msg = userInfo.getUsername() + "[" + userInfo.getAccount() + "]调用了Action方法["
          + request.getParameter("reqCode") + "]";
      dto.put("description", msg);
      log.info(msg + ";请求路径[" + request.getRequestURI() + "]");
    }
    MonitorService monitorService = (MonitorService) SpringBeanLoader.getSpringBean("monitorService");
    monitorService.saveEvent(dto);

  }
View Full Code Here

Examples of org.g4studio.system.admin.service.MonitorService

    } catch (Exception e) {
      success = false;
      e.printStackTrace();
    }
    if (success) {
      MonitorService monitorService = (MonitorService) SpringBeanLoader.getSpringBean("monitorService");
      monitorService.deleteHttpSession(new BaseDto());
      try {
        initDbType();
      } catch (SQLException e) {
        e.printStackTrace();
      }
View Full Code Here

Examples of org.g4studio.system.admin.service.MonitorService

    if (session == null) return;
    SessionContainer sessionContainer =  (SessionContainer)session.getAttribute("SessionContainer");
    if (sessionContainer == null) return;
    sessionContainer.setUserInfo(null); //配合RequestFilter进行拦截
    sessionContainer.cleanUp();
    MonitorService monitorService = (MonitorService)SpringBeanLoader.getSpringBean("monitorService");
    Dto dto = new BaseDto();
    dto.put("sessionid", session.getId());
    monitorService.deleteHttpSession(dto);
    ht.remove(session.getId());
    log.info("销毁了一个Session连接:" + session.getId() + " " + G4Utils.getCurrentTime());
  }
View Full Code Here

Examples of org.g4studio.system.admin.service.MonitorService

   * @param session
   */
  static public void addSession(HttpSession session, UserInfoVo userInfo) {
    ht.put(session.getId(), session);
    Reader g4Reader = (Reader)SpringBeanLoader.getSpringBean("g4Reader");
    MonitorService monitorService = (MonitorService)SpringBeanLoader.getSpringBean("monitorService");
    UserInfoVo usInfo = (UserInfoVo)g4Reader.queryForObject("Monitor.queryHttpSessionsByID", session.getId());
    if(G4Utils.isEmpty(usInfo)){
      monitorService.saveHttpSession(userInfo);
    }
  }
View Full Code Here

Examples of org.modeshape.jboss.metric.MonitorService

                                                                               defaultBinaryService);
        binaryStorageBuilder.addDependency(dataDirServiceName, String.class, defaultBinaryService.getDataDirectoryPathInjector());
        binaryStorageBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

        // Add monitor service
        final MonitorService monitorService = new MonitorService();
        final ServiceBuilder<RepositoryMonitor> monitorBuilder = target.addService(ModeShapeServiceNames.monitorServiceName(repositoryName),
                                                                                   monitorService);
        monitorBuilder.addDependency(ModeShapeServiceNames.repositoryServiceName(repositoryName),
                                     JcrRepository.class,
                                     monitorService.getJcrRepositoryInjector());
        monitorBuilder.setInitialMode(ServiceController.Mode.ACTIVE);

        // Now add the controller for the RepositoryService ...
        newControllers.add(repositoryServiceBuilder.install());
        newControllers.add(referenceBuilder.install());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.