Package com.linkedin.helix.healthcheck

Examples of com.linkedin.helix.healthcheck.HealthStatsAggregationTask


        new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
    Assert.assertTrue(result);
    Thread.sleep(3000);
    // HealthAggregationTask is supposed to run by a timer every 30s
    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
    new HealthStatsAggregationTask(cmResult._manager).run();

    //sleep for a few seconds to give stats stage time to trigger and for bean to trigger
    Thread.sleep(3000);

    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_zkClient));
View Full Code Here


    Assert.assertTrue(result);

    Thread.sleep(1000);
    // HealthAggregationTask is supposed to run by a timer every 30s
    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
    new HealthStatsAggregationTask(cmResult._manager).run();
  //sleep for a few seconds to give stats stage time to trigger
    Thread.sleep(3000);

    // other verifications go here
    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_zkClient));
View Full Code Here

        new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
    Assert.assertTrue(result);

    // HealthAggregationTask is supposed to run by a timer every 30s
    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
    new HealthStatsAggregationTask(cmResult._manager).run();
  //sleep for a few seconds to give stats stage time to trigger
    Thread.sleep(3000);

    // other verifications go here
    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_zkClient));
View Full Code Here

    // drop alert soon after adding, but leave enough time for alert to fire once
    // Thread.sleep(3000);
    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_zkClient));
    Builder keyBuilder = accessor.keyBuilder();

    new HealthStatsAggregationTask(cmResult._manager).run();
    String instance = "localhost_12918";
    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
    Map<String, Map<String, String>> recMap = record.getMapFields();
    Set<String> keySet = recMap.keySet();
    Assert.assertTrue(keySet.size() > 0);

    _setupTool.getClusterManagementTool().dropAlert(clusterName, _alertStr);
    new HealthStatsAggregationTask(cmResult._manager).run();
    // other verifications go here
    // for (int i = 0; i < 1; i++) //change 1 back to 5
    // {
    // String instance = "localhost_" + (12918 + i);
    record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
View Full Code Here

    ConfigScope scope = new ConfigScopeBuilder().forCluster(CLUSTER_NAME).build();
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("healthChange.enabled", "false");
    _setupTool.getClusterManagementTool().setConfig(scope, properties);
   
    HealthStatsAggregationTask task = new HealthStatsAggregationTask(_startCMResultMap.get(controllerName)._manager);
    task.run();
    Thread.sleep(100);
    HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
    Builder keyBuilder = helixDataAccessor.keyBuilder();

    AlertHistory history = manager.getHelixDataAccessor().getProperty(keyBuilder.alertHistory());
    //
    Assert.assertEquals(history, null);
   
    properties.put("healthChange.enabled", "true");
    _setupTool.getClusterManagementTool().setConfig(scope, properties);
   
    task.run();
    Thread.sleep(100);
   
    history = manager.getHelixDataAccessor().getProperty(keyBuilder.alertHistory());
    //
    Assert.assertNotNull(history);
View Full Code Here

    {
      history = property.getRecord();
      historySize = property.getRecord().getMapFields().size();
    }
   
    HealthStatsAggregationTask task = new HealthStatsAggregationTask(_startCMResultMap.get(controllerName)._manager);
    task.run();
    Thread.sleep(100);
   
   
    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
    //
    Assert.assertEquals(history.getMapFields().size(), 1 + historySize);
    TreeMap<String, Map<String, String>> recordMap = new TreeMap<String, Map<String, String>>();
    recordMap.putAll( history.getMapFields());
    Map<String, String> lastRecord = recordMap.firstEntry().getValue();
    Assert.assertTrue(lastRecord.size() == 4);
    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
   
    setHealthData(metrics1, metrics2);
    task.run();
    Thread.sleep(100);
    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
    // no change
    Assert.assertEquals(history.getMapFields().size(), 1 + historySize);
    recordMap = new TreeMap<String, Map<String, String>>();
    recordMap.putAll( history.getMapFields());
    lastRecord = recordMap.firstEntry().getValue();
    Assert.assertTrue(lastRecord.size() == 4);
    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
   
    int [] metrics3 = {21, 44, 22, 14, 16};
    int [] metrics4 = {122, 115, 222, 41,16};
    setHealthData(metrics3, metrics4);
    task.run();
    Thread.sleep(100);
    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
    // new delta should be recorded
    Assert.assertEquals(history.getMapFields().size(), 2 + historySize);
    recordMap = new TreeMap<String, Map<String, String>>();
    recordMap.putAll( history.getMapFields());
    lastRecord = recordMap.lastEntry().getValue();
    Assert.assertEquals(lastRecord.size(), 6);
    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
   
    int [] metrics5 = {0, 0, 0, 0, 0};
    int [] metrics6 = {0, 0, 0, 0,0};
    setHealthData(metrics5, metrics6);
    task.run();
    Thread.sleep(500);
    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
    // reset everything
    Assert.assertEquals(history.getMapFields().size(), 3 + historySize);
    recordMap = new TreeMap<String, Map<String, String>>();
    recordMap.putAll( history.getMapFields());
    lastRecord = recordMap.lastEntry().getValue();
    Assert.assertTrue(lastRecord.size() == 6);
    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
   
    // Size of the history should be 30
    for(int i = 0;i < 27; i++)
    {
      int x = i % 2;
      int y = (i+1) % 2;
      int[] metricsx = {19 + 3*x, 19 + 3*y, 19 + 4*x, 18+4*y, 17+5*y};
      int[] metricsy = {99 + 3*x, 99 + 3*y, 98 + 4*x, 98+4*y, 97+5*y};
     
      setHealthData(metricsx, metricsy);
      task.run();
      Thread.sleep(100);
      history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
     
      Assert.assertEquals(history.getMapFields().size(), Math.min(3 + i + 1 + historySize, 30));
      recordMap = new TreeMap<String, Map<String, String>>();
      recordMap.putAll( history.getMapFields());
      lastRecord = recordMap.lastEntry().getValue();
      if(i == 0)
      {
        Assert.assertTrue(lastRecord.size() == 6);
        Assert.assertTrue(lastRecord.get("(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
        Assert.assertTrue(lastRecord.get("(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
        Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
        Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
        Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
        Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
      }
      else
      {
        System.out.println(lastRecord.size());
        Assert.assertEquals(lastRecord.size() , 10);
        if(x == 0)
        {
          Assert.assertTrue(lastRecord.get("(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
        }
        else
        {
          Assert.assertTrue(lastRecord.get("(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
          Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
          Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
        }
      }
    }
    // size limit is 30
    for(int i = 0;i < 10; i++)
    {
      int x = i % 2;
      int y = (i+1) % 2;
      int[] metricsx = {19 + 3*x, 19 + 3*y, 19 + 4*x, 18+4*y, 17+5*y};
      int[] metricsy = {99 + 3*x, 99 + 3*y, 98 + 4*x, 98+4*y, 97+5*y};
     
      setHealthData(metricsx, metricsy);
      task.run();
      Thread.sleep(100);
      history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
     
      Assert.assertEquals(history.getMapFields().size(), 30);
      recordMap = new TreeMap<String, Map<String, String>>();
View Full Code Here

    // add all timer tasks
    _controllerTimerTasks = new ArrayList<HelixTimerTask>();
    if (_instanceType == InstanceType.CONTROLLER)
    {
      _controllerTimerTasks.add(new HealthStatsAggregationTask(this));
    }
  }
View Full Code Here

        new ClusterStateVerifier.BestPossAndExtViewZkVerifier(ZK_ADDR, clusterName));
    Assert.assertTrue(result);

    // HealthAggregationTask is supposed to run by a timer every 30s
    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
    new HealthStatsAggregationTask(cmResult._manager).run();
    //sleep for a few seconds to give stats stage time to trigger
    Thread.sleep(3000);

    // other verifications go here
    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_zkClient));
View Full Code Here

    Assert.assertTrue(result);

    Thread.sleep(1000);
    // HealthAggregationTask is supposed to run by a timer every 30s
    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
    new HealthStatsAggregationTask(cmResult._manager).run();
    //sleep for a few seconds to give stats stage time to trigger
    Thread.sleep(1000);

    // other verifications go here
    ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_zkClient));
    Builder keyBuilder = accessor.keyBuilder();
    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
    Map<String, Map<String,String>> recMap = record.getMapFields();
    for(int i = 0; i < 2; i++)
    {
      String alertString = "(localhost_"+(12944 + i)+".RestQueryStats@DBName=TestDB0.latency)";
      Map<String,String> alertStatusMap = recMap.get(alertwildcard+" : " + alertString);
      String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
      boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
      Assert.assertEquals(Double.parseDouble(val), (double)i * 5 + 0.1);
      Assert.assertFalse(fired);
    }
    for(int i = 2; i < 5; i++)
    {
      String alertString = "(localhost_"+(12944 + i)+".RestQueryStats@DBName=TestDB0.latency)";
      Map<String,String> alertStatusMap = recMap.get(alertwildcard+" : " + alertString);
      String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
      boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
      Assert.assertEquals(Double.parseDouble(val), (double)i * 5 + 0.1);
      Assert.assertTrue(fired);
    }
    ZNRecord alertHistory = accessor.getProperty(keyBuilder.alertHistory()).getRecord();
   
    String deltakey = (String) (alertHistory.getMapFields().keySet().toArray()[0]);
    Map<String, String> delta = alertHistory.getMapField(deltakey);
    Assert.assertEquals(delta.size() , 3);
    for(int i = 2; i < 5; i++)
    {
      String alertString = "(localhost_"+(12944 + i)+".RestQueryStats@DBName#TestDB0.latency)GREATER(10)";
      Assert.assertTrue(delta.get(alertString).equals("ON"));
    }
   
    // Drop and add another alert
    _setupTool.getClusterManagementTool().dropAlert(clusterName, alertwildcard);
    alertwildcard = "EXP(decay(1.0)(localhost*.RestQueryStats@DBName=TestDB0.latency))CMP(GREATER)CON(15)";
    _setupTool.getClusterManagementTool().addAlert(clusterName, alertwildcard);
    new HealthStatsAggregationTask(cmResult._manager).run();
    Thread.sleep(1000);
   
    record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
    recMap = record.getMapFields();
    for(int i = 0; i < 3; i++)
View Full Code Here

    // add all timer tasks
    _controllerTimerTasks = new ArrayList<HelixTimerTask>();
    if (_instanceType == InstanceType.CONTROLLER)
    {
      _controllerTimerTasks.add(new HealthStatsAggregationTask(this));
    }
  }
View Full Code Here

TOP

Related Classes of com.linkedin.helix.healthcheck.HealthStatsAggregationTask

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.