/** * Adds a new evaluator with a weight of 1.0. * * @param evaluator The new evaluator. */ public void addEvaluator(IServiceEvaluator evaluator) { addEvaluator(evaluator, 1.0); }
/** * Adds a new evaluator with a weight of 1.0. * * @param evaluator The new evaluator. */ public void addEvaluator(IServiceEvaluator evaluator) { addEvaluator(evaluator, 1.0); }
ce.addEvaluator(new BasicEvaluator<Double>(agent.getExternalAccess(), "fakecpuload") ce.addEvaluator(new BasicEvaluator<Double>(agent.getExternalAccess(), "fakereliability") ce.addEvaluator(new BasicEvaluator<Long>(agent.getExternalAccess(), "fakefreemem", MemoryUnit.MB) ce.addEvaluator(new BasicEvaluator<Long>(agent.getExternalAccess(), "fakenetworkbandwith", MemoryUnit.MB)
/** * The agent body. */ @AgentBody public void body() { // todo: make ITerminable in DefaultServiceFetcher try { while(true) { ComposedEvaluator<IAService> ranker = new ComposedEvaluator<IAService>(); ranker.addEvaluator(new ExecutionTimeEvaluator(agent.getExternalAccess(), new MethodInfo(IAService.class.getMethod("test", new Class[0])), true)); ITerminableIntermediateFuture<IAService> sfut = agent.getComponentFeature(IRequiredServicesFeature.class).getRequiredServices("aser"); Collection<Tuple2<IAService, Double>> res = SServiceProvider.rankServicesWithScores(sfut, ranker, null).get(); System.out.println("Found: "+res); IAService aser = res.iterator().next().getFirstEntity(); aser.test().get(); } } catch(Exception e) { System.out.println("User agent problem: "+e); } }
/** * The agent body. */ @AgentBody public void body() throws Exception { // todo: make ITerminable in DefaultServiceFetcher // problem with execution time evaluator scheduling: // all use the best service until that service time drops below the level of the second // then all use the second and the second level drops hardly and cannot recover because // no one will ever use it again ranker = new ComposedEvaluator<ICryptoService>(); AverageEvaluator eva = new AverageEvaluator(new WaitqueueEvaluator(agent.getExternalAccess(), new MethodInfo(ICryptoService.class.getMethod("encrypt", new Class[]{String.class})))); ranker.addEvaluator(eva); // ranker.addEvaluator(new ExecutionTimeEvaluator(new MethodInfo(IAService.class.getMethod("test", new Class[0])))); invoke(); }