/** Collect agent system data every second. */
 @Scheduled(fixedDelay = 1000)
 public void collectAgentSystemData() {
   Ehcache nativeCache = (Ehcache) agentMonioringTargetsCache.getNativeCache();
   List<String> keysWithExpiryCheck = convert(nativeCache.getKeysWithExpiryCheck());
   for (String each : keysWithExpiryCheck) {
     ValueWrapper value = agentMonioringTargetsCache.get(each);
     if (value != null && value.get() != null) {
       writeObjectToFile(
           getAgentPath(each), getAgentManager().getSystemDataModel((AgentIdentity) value.get()));
     }
   }
 }
Beispiel #2
0
  public static void main(String... args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    ClassroomService classroomService = context.getBean(ClassroomService.class);

    Teacher teacher = new Teacher(1, "Mert");
    Student student1 = new Student(2, "Tugce");

    Person personFetch1 = classroomService.getPerson(teacher);
    System.out.println(personFetch1);

    Person personFetch2 = classroomService.getPerson(student1);
    System.out.println(personFetch2);

    CacheManager cacheManager = context.getBean(CacheManager.class);
    Cache students = cacheManager.getCache("students");
    System.out.println(
        "students cache storage: " + ((ConcurrentHashMap) students.getNativeCache()).values());
    Cache teachers = cacheManager.getCache("teachers");
    System.out.println(
        "teachers cache storage: " + ((ConcurrentHashMap) teachers.getNativeCache()).values());
  }