Examples of Instrumentation


Examples of com.android.ide.common.xml.ManifestData.Instrumentation

                        mManifestData.mPackage, instrumentationName);
                String targetPackage = getAttributeValue(attributes,
                        AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
                        true /* hasNamespace */);
                mManifestData.mInstrumentations.add(
                        new Instrumentation(instrClassName, targetPackage));
                if (mErrorHandler != null) {
                    mErrorHandler.checkClass(mLocator, instrClassName,
                            SdkConstants.CLASS_INSTRUMENTATION, true /* testVisibility */);
                }
            }
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

        Groups groups = HoopServer.get().get(Groups.class);
        List<String> userGroups = groups.getGroups(user.getName());
        if (!userGroups.contains(HoopServer.get().getAdminGroup())) {
          throw new AccessControlException("User not in Hoop admin group");
        }
        Instrumentation instrumentation = HoopServer.get().get(Instrumentation.class);
        Map snapshot = instrumentation.getSnapshot();
        response = Response.ok(snapshot).build();
        break;
      }
    }
    return response;
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

  }

  @Override
  public void postInit() throws ServiceException {
    super.postInit();
    Instrumentation instrumentation = getServer().get(Instrumentation.class);
    instrumentation.addVariable(INSTRUMENTATION_GROUP, "unmanaged.fs", new Instrumentation.Variable<Integer>() {
      @Override
      public Integer getValue() {
        return unmanagedFileSystems.get();
      }
    });
    instrumentation.addSampler(INSTRUMENTATION_GROUP, "unmanaged.fs", 60, new Instrumentation.Variable<Long>() {
      @Override
      public Long getValue() {
        return (long) unmanagedFileSystems.get();
      }
    });
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

      UserGroupInformation ugi = getUGI(user);
      return ugi.doAs(new PrivilegedExceptionAction<T>() {
        public T run() throws Exception {
          Configuration namenodeConf = createNameNodeConf(conf);
          FileSystem fs = createFileSystem(namenodeConf);
          Instrumentation instrumentation = getServer().get(Instrumentation.class);
          Instrumentation.Cron cron = instrumentation.createCron();
          try {
            checkNameNodeHealth(fs);
            cron.start();
            return executor.execute(fs);
          }
          finally {
            cron.stop();
            instrumentation.addCron(INSTRUMENTATION_GROUP, executor.getClass().getSimpleName(), cron);
            closeFileSystem(fs);
          }
        }
      });
    }
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

          Configuration namenodeConf = createNameNodeConf(conf);
          JobClient jobClient = createJobClient(jobtrackerConf);
          try {
            checkJobTrackerHealth(jobClient);
            FileSystem fs = createFileSystem(namenodeConf);
            Instrumentation instrumentation = getServer().get(Instrumentation.class);
            Instrumentation.Cron cron = instrumentation.createCron();
            try {
              checkNameNodeHealth(fs);
              cron.start();
              return executor.execute(jobClient, fs);
            }
            finally {
              cron.stop();
              instrumentation.addCron(INSTRUMENTATION_GROUP, executor.getClass().getSimpleName(), cron);
              closeFileSystem(fs);
            }
          }
          finally {
            closeJobClient(jobClient);
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

      LOG.debug("Scheduling callable [{}], interval [{}] seconds, delay [{}] in [{}]",
                new Object[]{callable, delay, interval, unit});
      Runnable r = new Runnable() {
        public void run() {
          String instrName = callable.getClass().getSimpleName();
          Instrumentation instr = getServer().get(Instrumentation.class);
          if (getServer().getStatus() == Server.Status.HALTED) {
            LOG.debug("Skipping [{}], server status [{}]", callable, getServer().getStatus());
            instr.incr(INST_GROUP, instrName + ".skips", 1);
          }
          else {
            LOG.debug("Executing [{}]", callable);
            instr.incr(INST_GROUP, instrName + ".execs", 1);
            Instrumentation.Cron cron = instr.createCron().start();
            try {
              callable.call();
            }
            catch (Exception ex) {
              instr.incr(INST_GROUP, instrName + ".fails", 1);
              LOG.error("Error executing [{}], {}", new Object[]{callable, ex.getMessage(), ex});
            }
            finally {
              instr.addCron(INST_GROUP, instrName, cron.stop());
            }
          }
        }
      };
      scheduler.scheduleWithFixedDelay(r, delay, interval, unit);
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

    XConfiguration conf = new XConfiguration();
    conf.set("server.services", services);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();

    Instrumentation instrumentation = server.get(Instrumentation.class);
    Assert.assertNotNull(instrumentation);
    instrumentation.incr("g", "c", 1);
    instrumentation.incr("g", "c", 2);
    instrumentation.incr("g", "c1", 2);

    Instrumentation.Cron cron = instrumentation.createCron();
    cron.start();
    sleep(100);
    cron.stop();
    instrumentation.addCron("g", "t", cron);
    cron = instrumentation.createCron();
    cron.start();
    sleep(200);
    cron.stop();
    instrumentation.addCron("g", "t", cron);

    Instrumentation.Variable<String> var = new Instrumentation.Variable<String>() {
      @Override
      public String getValue() {
        return "foo";
      }
    };
    instrumentation.addVariable("g", "v", var);

    Instrumentation.Variable<Long> varToSample = new Instrumentation.Variable<Long>() {
      @Override
      public Long getValue() {
        return 1L;
      }
    };
    instrumentation.addSampler("g", "s", 10, varToSample);

    Map<String, ?> snapshot = instrumentation.getSnapshot();
    Assert.assertNotNull(snapshot.get("os-env"));
    Assert.assertNotNull(snapshot.get("sys-props"));
    Assert.assertNotNull(snapshot.get("jvm"));
    Assert.assertNotNull(snapshot.get("counters"));
    Assert.assertNotNull(snapshot.get("timers"));
View Full Code Here

Examples of com.cloudera.lib.service.Instrumentation

                                                         SchedulerService.class.getName()), ",");
    XConfiguration conf = new XConfiguration();
    conf.set("server.services", services);
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    Instrumentation instrumentation = server.get(Instrumentation.class);

    final AtomicInteger count = new AtomicInteger();

    Instrumentation.Variable<Long> varToSample = new Instrumentation.Variable<Long>() {
      @Override
      public Long getValue() {
        return (long) count.incrementAndGet();
      }
    };
    instrumentation.addSampler("g", "s", 10, varToSample);

    sleep(2000);
    int i = count.get();
    Assert.assertTrue(i > 0);

    Map<String, Map<String, ?>> snapshot = instrumentation.getSnapshot();
    Map<String, Map<String, Object>> samplers = (Map<String, Map<String, Object>>) snapshot.get("samplers");
    InstrumentationService.Sampler sampler = (InstrumentationService.Sampler) samplers.get("g").get("s");
    Assert.assertTrue(sampler.getRate() > 0);

    server.destroy();
View Full Code Here

Examples of com.google.caliper.runner.Instrument.Instrumentation

            .toSet());
  }

  @Test public void createInstrumentation_macrobenchmark() throws Exception {
    Method benchmarkMethod = RuntimeBenchmark.class.getDeclaredMethod("macrobenchmark");
    Instrumentation instrumentation = instrument.createInstrumentation(benchmarkMethod);
    assertEquals(benchmarkMethod, instrumentation.benchmarkMethod());
    assertEquals(instrument, instrumentation.instrument());
    assertEquals(MacrobenchmarkWorker.class, instrumentation.workerClass());
  }
View Full Code Here

Examples of java.lang.instrument.Instrumentation

        final Map<Class,byte[]> classes) {
        Log log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
        if (classes == null || classes.size() == 0)
            return;

        Instrumentation inst = null;
        ClassFileTransformer t = null;
        try {
            inst = InstrumentationFactory.getInstrumentation();

            Class[] array = classes.keySet().toArray(new Class[classes.size()]);
            if (JavaVersions.VERSION >= 6) {
                log.trace(_loc.get("retransform-types", classes.keySet()));

                t = new ClassFileTransformer() {
                    public byte[] transform(ClassLoader loader, String clsName,
                        Class<?> classBeingRedefined, ProtectionDomain pd,
                        byte[] classfileBuffer) {
                        return classes.get(classBeingRedefined);
                    }
                };
               
                // these are Java 6 methods, and we don't have a Java 6 build
                // module yet. The cost of reflection here is negligible
                // compared to the redefinition / enhancement costs in total,
                // so this should not be a big problem.
                Method meth = inst.getClass().getMethod("addTransformer",
                    new Class[] { ClassFileTransformer.class, boolean.class });
                meth.invoke(inst, new Object[] { t, true });
                meth = inst.getClass().getMethod("retransformClasses",
                    new Class[] { array.getClass() });
                meth.invoke(inst, new Object[] { array });
            } else {
                log.trace(_loc.get("redefine-types", classes.keySet()));
                // in a Java 5 context, we can use class redefinition instead
                ClassDefinition[] defs = new ClassDefinition[array.length];
                for (int i = 0; i < defs.length; i++)
                    defs[i] = new ClassDefinition(array[i],
                        classes.get(array[i]));
                inst.redefineClasses(defs);
            }
        } catch (NoSuchMethodException e) {
            throw new InternalException(e);
        } catch (IllegalAccessException e) {
            throw new InternalException(e);
        } catch (InvocationTargetException e) {
            throw new UserException(e.getCause());
        } catch (IOException e) {
            throw new InternalException(e);
        } catch (ClassNotFoundException e) {
            throw new InternalException(e);
        } catch (UnmodifiableClassException e) {
            throw new InternalException(e);
        } finally {
            if (inst != null && t != null)
                inst.removeTransformer(t);
        }
    }
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.