@SuppressWarnings("unchecked") public <T extends IMetric> T registerMetric(String name, T metric, int timeBucketSizeInSecs) { if ((Boolean) _openOrPrepareWasCalled.deref()) { throw new RuntimeException("TopologyContext.registerMetric can only be called from within overridden " + "IBolt::prepare() or ISpout::open() method.");
public <T extends IMetric> T registerMetric(String name, T metric, int timeBucketSizeInSecs) { if((Boolean)_openOrPrepareWasCalled.deref() == true) { throw new RuntimeException("TopologyContext.registerMetric can only be called from within overridden " + "IBolt::prepare() or ISpout::open() method."); } if (metric == null) { throw new IllegalArgumentException("Cannot register a null metric"); } if (timeBucketSizeInSecs <= 0) { throw new IllegalArgumentException("TopologyContext.registerMetric can only be called with timeBucketSizeInSecs " + "greater than or equal to 1 second."); } Map m1 = _registeredMetrics; if(!m1.containsKey(timeBucketSizeInSecs)) { m1.put(timeBucketSizeInSecs, new HashMap()); } Map m2 = (Map)m1.get(timeBucketSizeInSecs); if(!m2.containsKey(_taskId)) { m2.put(_taskId, new HashMap()); } Map m3 = (Map)m2.get(_taskId); if(m3.containsKey(name)) { throw new RuntimeException("The same metric name `" + name + "` was registered twice." ); } else { m3.put(name, metric); } return metric; }
public <T extends IMetric> T registerMetric(String name, T metric, int timeBucketSizeInSecs) { if ((Boolean) _openOrPrepareWasCalled.deref() == true) { throw new RuntimeException("TopologyContext.registerMetric can only be called from within overridden " + "IBolt::prepare() or ISpout::open() method.");
@Deprecated public <T extends IMetric> T registerMetric(String name, T metric, int timeBucketSizeInSecs) { if((Boolean) _openOrPrepareWasCalled.deref()) { throw new RuntimeException("TopologyContext.registerMetric can only be called from within overridden " + "IBolt::prepare() or ISpout::open() method.");
public Object swap(IFn f, Object arg1, Object arg2) { for(; ;) { Object v = deref(); Object newv = f.invoke(v, arg1, arg2); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f) { for(; ;) { Object v = deref(); Object newv = f.invoke(v); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f, Object arg1, Object arg2) { for(; ;) { Object v = deref(); Object newv = f.invoke(v, arg1, arg2); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f, Object arg) { for(; ;) { Object v = deref(); Object newv = f.invoke(v, arg); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f) { for(; ;) { Object v = deref(); Object newv = f.invoke(v); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f, Object arg) { for(; ;) { Object v = deref(); Object newv = f.invoke(v, arg); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f, Object x, Object y, ISeq args) { for(; ;) { Object v = deref(); Object newv = f.applyTo(RT.listStar(v, x, y, args)); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Object swap(IFn f, Object x, Object y, ISeq args) { for(; ;) { Object v = deref(); Object newv = f.applyTo(RT.listStar(v, x, y, args)); validate(newv); if(state.compareAndSet(v, newv)) { notifyWatches(v, newv); return newv; } } }
public Model read(final Reader input, final Map<String, ?> options) throws IOException { assert input != null; try { String location = PolyglotModelUtil.getLocation(options); final Var USE = Var.intern(RT.CLOJURE_NS, Symbol.create("use")); final Symbol READER = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.reader"); final Symbol LEININGEN = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.leiningen"); USE.invoke(READER); USE.invoke(LEININGEN); clojure.lang.Compiler.load(input, location, location); final Var MODEL = Var.intern(Namespace.findOrCreate(READER), Symbol.create("*MODEL*")); return (Model) ((Atom) MODEL.get()).deref(); } catch (Exception e) { // Don't use new IOException(e) because it doesn't exist in Java 5 throw (IOException) new IOException(e.toString()).initCause(e); } } }