当前位置: 首页>>代码示例>>Java>>正文


Java IObservable类代码示例

本文整理汇总了Java中eu.qualimaster.observables.IObservable的典型用法代码示例。如果您正苦于以下问题:Java IObservable类的具体用法?Java IObservable怎么用?Java IObservable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IObservable类属于eu.qualimaster.observables包,在下文中一共展示了IObservable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValue

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Returns the value of an observable in <code>elt</code>.
 * 
 * @param elt the IVML element to return the value for
 * @param observable the observable
 * @return the value, may be <b>null</b> if not defined
 */
private Double getValue(IvmlElement elt, IObservable observable) {
    Double result = null;
    if (null != state && elt instanceof AbstractIvmlVariable) {
        AbstractIvmlVariable var = (AbstractIvmlVariable) elt;
        TypeCharacterizer characterizer = TypeMapper.findCharacterizer(var.getIvmlType());
        if (null != characterizer) {
            String prefix = characterizer.getFrozenStatePrefix();
            String key = characterizer.getFrozenStateKey(var.getDecisionVariable());
            if (null != prefix && null != key) {
                result = state.getObservation(prefix, key, observable, null);
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:23,代码来源:RtVilValueMapping.java

示例2: testStorage

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Tests string-to-key and back functionality.
 */
@Test
public void testStorage() {
    IStorageStrategy strategy = DefaultStorageStrategy.INSTANCE;
    Pipeline pip = AlgorithmProfilePredictionManager.obtainPipeline("pip");
    PipelineElement elt = pip.obtainElement("elt");
    IObservable obs = TimeBehavior.LATENCY;
    Map<Object, Serializable> key = new HashMap<Object, Serializable>();
    key.put(Constants.KEY_INPUT_RATE, 100);
    key.put(ResourceUsage.EXECUTORS, 5);
    String k = strategy.generateKey(elt, key, obs, true);
    ProfileKey pKey = strategy.parseKey(k);
    Assert.assertEquals(pip.getName(), pKey.getPipeline());
    Assert.assertEquals(elt.getName(), pKey.getElement());
    Assert.assertEquals(obs, pKey.getObservable());
    Assert.assertEquals(key, pKey.getParameter());
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:20,代码来源:UtilsTest.java

示例3: tracePartsHeader

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Traces the header for the observables of the parts of <code>alg</code>.
 * 
 * @param alg the algorithm to trace the parts for
 * @param exclude observables to exclude - trace only other others (may be <b>null</b>)
 * @param include observables to include - trace only those (may be <b>null</b>)
 */
protected void tracePartsHeader(NodeImplementationSystemPart alg, IObservable[] exclude, 
    IObservable[] include) {
    printSeparator();
    for (PipelineNodeSystemPart part : nodeSequence(alg)) {
        String prefix = "part." + part.getName() + ".";
        traceHeader(part, prefix, exclude, include);
        printSeparator();
        if (mode.traceTasks()) {
            Processor proc = getProcessor(part);
            if (null != proc && null != proc.tasks()) {
                for (Integer taskId : proc.tasks()) {
                    String taskIdPrefix = prefix + taskId + ".";
                    traceHeader(part, taskIdPrefix, exclude, include);
                    print(taskIdPrefix + "host");
                    printSeparator();
                }
            }
        }
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:28,代码来源:AbstractFileTrace.java

示例4: assertAlgorithmObservation

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Assert an algorithm observation. 
 * 
 * @param expected the expected value
 * @param state the frozen state to look into
 * @param alg the algorithm to took into
 * @param observable the observable to assert
 * @param deflt the default value in case that there is no value
 */
private static void assertAlgorithmObservation(Double expected, FrozenSystemState state, 
    NodeImplementationSystemPart alg, IObservable observable, Double deflt) {
    Double val = state.getAlgorithmObservation(alg.getPipeline().getName(), alg.getName(), observable, deflt);
    if (null == expected) {
        Assert.assertNull(val);
    } else {
        Assert.assertNotNull(val);
        Assert.assertEquals(expected.doubleValue(), val.doubleValue(), ASSERTION_PRECISION);
    }
    
    val = alg.getObservedValue(observable);
    if (null == expected) {
        Assert.assertNull(val);
    } else {
        Assert.assertNotNull(val);
        Assert.assertEquals(expected.doubleValue(), val.doubleValue(), ASSERTION_PRECISION);
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:28,代码来源:ValueBindingTest.java

示例5: parseApproximatorFileName

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
@Override
public ApproximatorInfo parseApproximatorFileName(String fileName) {
    ApproximatorInfo result = null;
    String name = fileName;
    int pos = name.lastIndexOf('.');
    if (pos > 0) {
        name = name.substring(0, pos);
    }
    // name constants for observables shall not contain a - (naming conventions)
    pos = name.lastIndexOf("-");
    if (pos > 0 && pos < name.length()) { // somewhere in-between
        IObservable obs = Observables.valueOf(name.substring(pos + 1));
        if (null != obs) {
            result = new ApproximatorInfo(name.substring(0, pos), obs);
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:19,代码来源:DefaultStorageStrategy.java

示例6: assertEquals

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Asserts the equality of the given <code>expected</code> boolean value for <code>part</code> and 
 * <code>frozen</code> on <code>observable</code>.
 * 
 * @param expected the expected value
 * @param part the system part to test
 * @param frozen the frozen system state to test
 * @param observable the observable to test the value for
 */
public static void assertEquals(boolean expected, SystemPart part, FrozenSystemState frozen, 
    IObservable observable) {
    double expectedVal = expected ? 1.0 : 0.0; 
    
    Double obs = part.getObservedValue(observable);
    Assert.assertNotNull(obs);
    Assert.assertEquals(expectedVal, obs, 0.05);
    if (PartType.CLUSTER == part.getType()) {
        obs = frozen.getHwNodeObservation(part.getName(), ResourceUsage.AVAILABLE, 0.0);
    } else if (PartType.MACHINE == part.getType()) {
        obs = frozen.getMachineObservation(part.getName(), ResourceUsage.AVAILABLE, 0.0);
    } else {
        obs = null;
    }
    Assert.assertNotNull(obs);
    Assert.assertEquals(expectedVal, obs, 0.05);
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:27,代码来源:SystemStateTest.java

示例7: obtainPredictor

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Obtains a predictor and creates one if permissible.
 * 
 * @param observable the observable to obtain a predictor for
 * @return the predictor
 */
private IAlgorithmProfilePredictor obtainPredictor(IObservable observable) {
    IAlgorithmProfilePredictor predictor;
    synchronized (predictors) {
        predictor = predictors.get(observable);
    }
    if (null == predictor && null != ProfilingRegistry.getQuantizer(observable, false)) {
        predictor = element.getProfileCreator().createPredictor();
        try {
            load(predictor, getFolder(observable), generateKey(observable));
        } catch (IOException e) {
            LOGGER.error("While reading predictor: " + e.getMessage());
        }
        synchronized (predictors) {
            predictors.put(observable, predictor);
        }
    }
    return predictor;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:25,代码来源:SeparateObservableAlgorithmProfile.java

示例8: parseEvent

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
@Override
public PipelineElementMultiObservationMonitoringEvent parseEvent(String line, LogReader reader) {
    PipelineElementMultiObservationMonitoringEvent result = null;
    EventLineParser parser = new EventLineParser(line, reader.getErr());
    int startLineLength;
    Map<IObservable, Double> observations = null;
    String pipelineElement = null;
    ComponentKey key;
    String pipeline = null;
    do {
        startLineLength = line.length();
        observations = parser.parseObservations("observations");
        pipelineElement = parser.parseString("pipelineElement", pipelineElement, STOP);
        key = parser.parseComponentKey("key");
        pipeline = parser.parseString("pipeline", pipeline, STOP);
    } while (!parser.isEndOfLine(startLineLength));
    if (null != observations && null != pipelineElement && null != pipeline) { // key may be null
        result = new PipelineElementMultiObservationMonitoringEvent(pipeline, pipelineElement, key, observations);
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:22,代码来源:PipelineElementMultiObservationMonitoringEventReader.java

示例9: incrementValue

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
@Override
public void incrementValue(IObservable observable, Double value, Object key) {
    boolean doit = true;
    if (null != value && VALIDATE.contains(observable) && key instanceof ComponentKey) {
        Double val = getPipeline().validateComponent((ComponentKey) key, observable, value, true, this);
        if (val == 0.0) {
            doSetValue(observable, 0.0, key);
            doit = false;
        } else if (null != val) {
            value = val;
        } else {
            doit = false;
        }
    } 
    if (doit) {
        super.incrementValue(observable, value, key);
        if (null != current && ILinkSelector.enablePropagation(observable)) {
            current.incrementValue(observable, value, key);
        }
        if (null != parent) {
            parent.incrementValue(observable, value, key);
        }
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:25,代码来源:PipelineNodeSystemPart.java

示例10: getFromConfiguration

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Returns the value of the corresponding variable from the configuration.
 * 
 * @param provider the observation provider
 * @param observable the observable this observation is providing
 * @param deflt the default constant value of the observation
 * @return the value, if not accessible <code>deflt</code>
 */
private static double getFromConfiguration(IObservationProvider provider, IObservable observable, 
    double deflt) {
    double result = deflt;
    IObservationProvider parent = provider.getParent();
    if (null != parent) {
        String pipName = parent.getName(); // just assume and let's see
        String nodeName = provider.getName(); // node
        String varName = ObservableMapper.getMappedName(observable);
        Models models =  RepositoryConnector.getModels(Phase.MONITORING);
        if (null != models) {
            Configuration cfg = models.getConfiguration();
            IDecisionVariable pipeline = PipelineHelper.obtainPipelineByName(cfg, pipName);
            IDecisionVariable node = PipelineHelper.obtainPipelineElementByName(pipeline, null, nodeName);
            Double val = VariableHelper.getDouble(node, varName);
            if (null != val) {
                result = val;
            }
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:30,代码来源:ConfigurationConstantObservation.java

示例11: readObservation

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Reads an observation.
 * 
 * @param entry the entry to modify
 * @param token the token representing the observation
 * @param observables the observables in sequence
 * @param entryPos the position of the entry/observable
 * @return <code>true</code> if the next <code>entryPos</code> is out of range of <code>observables</code>, 
 *     <code>false</code> else
 * @throws IOException in case of reading errors
 */
private boolean readObservation(Entry entry, String token, List<IObservable> observables, int entryPos) 
    throws IOException {
    int pos = entryPos - 1; // -1 is name
    if (pos < observables.size()) {
        if (!token.isEmpty()) {
            IObservable obs = observables.get(pos);
            try {
                entry.addObservation(obs, Double.valueOf(token.replace(',', '.'))); // Excel back-mapping
            } catch (NumberFormatException e) {
                throw new IOException("[Error] Reading observation entry nr " + entryPos + ": " + e.getMessage());
            }
        }
    }
    return pos + 1 >= observables.size();
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:27,代码来源:TraceReader.java

示例12: getObservableSequence

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Returns the observables in output sequence. Considers {@link #LIMIT} and {@link #EXCLUDE}.
 * 
 * @param cls the part class to sort the observables (and to cache them for)
 * @param observables the observables related to <code>cls</code>
 * @return the sorted observables
 */
static IObservable[] getObservableSequence(Class<?> cls, Collection<IObservable> observables) {
    IObservable[] result = SEQUENCES.get(cls);
    if (null == result && null != observables) {
        TreeSet<IObservable> tmp = new TreeSet<IObservable>(ObservableComparator.INSTANCE);
        IObservable[] limit = LIMIT.get(cls.getClass());
        IObservable[] exclude = EXCLUDE.get(cls.getClass());
        for (IObservable observable : observables) {
            if ((null == limit || Arrays.contains(limit, observable)) 
                && (null == exclude || !Arrays.contains(exclude, observable))) {
                tmp.add(observable);
            }
        }
        result = new IObservable[tmp.size()];
        SEQUENCES.put(cls, tmp.toArray(result));
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:25,代码来源:Tracing.java

示例13: linkImpl

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
/**
 * Links/unlinks the observables of <code>part</code> from this observable.
 * 
 * @param part the part to take the observables to unlink from (may be <b>null</b>)
 * @param link to link or not to link
 * @param selector selects the relevant observables
 * @see #isLinkEnabled(IObservable)
 */
private void linkImpl(SystemPart part, boolean link, ILinkSelector selector) {
    if (null != part) {
        synchronized (part.parameterValues) {
            for (Map.Entry<IObservable, IObservation> value : part.parameterValues.entrySet()) {
                IObservable observable = value.getKey();
                if (selector.isLinkEnabled(observable)) {
                    IObservation observation = value.getValue();
                    IObservation myObservation = parameterValues.get(observable);
                    if (null != myObservation) {
                        if (link) {
                            myObservation.link(observation);
                        } else {
                            myObservation.unlink(observation);    
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:29,代码来源:SystemPart.java

示例14: clearComponents

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
@Override
public void clearComponents(IObservable observable, Collection<Object> keys) {
    super.clearComponents(observable, keys);
    if (null != parent) {
        parent.clearComponents(observable, keys);
    }
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:8,代码来源:PipelineNodeSystemPart.java

示例15: getObservedValueInt

import eu.qualimaster.observables.IObservable; //导入依赖的package包/类
@Override
public int getObservedValueInt(IObservable observable) {
    int result = 0;
    synchronized (parameterValues) {
        IObservation observation = parameterValues.get(observable);
        if (null != observation) {
            result = (int) observation.getValue();
        }
    }
    return result;
}
 
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:12,代码来源:SystemPart.java


注:本文中的eu.qualimaster.observables.IObservable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。