Beispiel #1
0
  /** Configure cacheEmployee. */
  private static <K, V> CacheConfiguration<K, V> cacheCar() {
    CacheConfiguration<K, V> ccfg = cacheConfiguration(CAR_CACHE_NAME);

    // Configure cacheCar types.
    Collection<QueryEntity> qryEntities = new ArrayList<>();

    // CAR.
    QueryEntity type = new QueryEntity();

    qryEntities.add(type);

    type.setKeyType(Integer.class.getName());
    type.setValueType(Car.class.getName());

    // Query fields for CAR.
    LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();

    qryFlds.put("id", "java.lang.Integer");
    qryFlds.put("parkingId", "java.lang.Integer");
    qryFlds.put("name", "java.lang.String");

    type.setFields(qryFlds);

    ccfg.setQueryEntities(qryEntities);

    return ccfg;
  }
Beispiel #2
0
  /** Configure cacheEmployee. */
  private static <K, V> CacheConfiguration<K, V> cacheEmployee() {
    CacheConfiguration<K, V> ccfg = cacheConfiguration(EMPLOYEE_CACHE_NAME);

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setBackups(1);

    // Configure cacheEmployee types.
    Collection<QueryEntity> qryEntities = new ArrayList<>();

    // EMPLOYEE.
    QueryEntity type = new QueryEntity();

    qryEntities.add(type);

    type.setKeyType(Integer.class.getName());
    type.setValueType(Employee.class.getName());

    // Query fields for EMPLOYEE.
    LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();

    qryFlds.put("id", "java.lang.Integer");
    qryFlds.put("departmentId", "java.lang.Integer");
    qryFlds.put("managerId", "java.lang.Integer");
    qryFlds.put("firstName", "java.lang.String");
    qryFlds.put("lastName", "java.lang.String");
    qryFlds.put("email", "java.lang.String");
    qryFlds.put("phoneNumber", "java.lang.String");
    qryFlds.put("hireDate", "java.sql.Date");
    qryFlds.put("job", "java.lang.String");
    qryFlds.put("salary", "java.lang.Double");

    type.setFields(qryFlds);

    // Indexes for EMPLOYEE.
    Collection<QueryIndex> indexes = new ArrayList<>();

    QueryIndex idx = new QueryIndex();

    idx.setName("EMP_NAMES");
    idx.setIndexType(QueryIndexType.SORTED);
    LinkedHashMap<String, Boolean> indFlds = new LinkedHashMap<>();

    indFlds.put("firstName", Boolean.FALSE);
    indFlds.put("lastName", Boolean.FALSE);

    idx.setFields(indFlds);

    indexes.add(idx);
    indexes.add(new QueryIndex("salary", QueryIndexType.SORTED, false, "EMP_SALARY"));

    type.setIndexes(indexes);

    ccfg.setQueryEntities(qryEntities);

    return ccfg;
  }
  /** {@inheritDoc} */
  @Override
  protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);

    CacheConfiguration ccfg = new CacheConfiguration();
    ccfg.setWriteSynchronizationMode(FULL_SYNC);

    QueryEntity person = new QueryEntity();
    person.setKeyType(TestKey.class.getName());
    person.setValueType(Person.class.getName());
    person.addQueryField("name", String.class.getName(), null);

    ccfg.setQueryEntities(Arrays.asList(person));

    cfg.setCacheConfiguration(ccfg);

    cfg.setMarshaller(null);

    return cfg;
  }