indexes for Registry map
This commit is contained in:
parent
fe48b00464
commit
02e2b3a3f2
3 changed files with 29 additions and 4 deletions
|
|
@ -1,8 +1,11 @@
|
||||||
package ru.spcex.clearing.imdg.base;
|
package ru.spcex.clearing.imdg.base;
|
||||||
|
|
||||||
|
import com.hazelcast.config.MapIndexConfig;
|
||||||
import com.hazelcast.core.MapLoader;
|
import com.hazelcast.core.MapLoader;
|
||||||
|
|
||||||
public interface AutoconfiguredMap<T> extends MapLoader<Long, T> {
|
public interface AutoconfiguredMap<T> extends MapLoader<Long, T> {
|
||||||
|
MapIndexConfig[] emptyIndexes = new MapIndexConfig[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return IMDGDistributedNames.*
|
* @return IMDGDistributedNames.*
|
||||||
|
|
@ -14,4 +17,8 @@ public interface AutoconfiguredMap<T> extends MapLoader<Long, T> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String[] getIndexingField();
|
String[] getIndexingField();
|
||||||
|
|
||||||
|
default MapIndexConfig[] getIndexes() {
|
||||||
|
return emptyIndexes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package ru.spcex.clearing.imdg.businessobject;
|
package ru.spcex.clearing.imdg.businessobject;
|
||||||
|
|
||||||
|
import com.hazelcast.config.MapIndexConfig;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -12,13 +13,23 @@ import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class RegistryMapStore extends TemplateMapStore<Registry> {
|
public class RegistryMapStore extends TemplateMapStore<Registry> {
|
||||||
|
|
||||||
|
private final MapIndexConfig[] indexes;
|
||||||
|
|
||||||
public RegistryMapStore(JdbcTemplate jdbcTemplate) {
|
public RegistryMapStore(JdbcTemplate jdbcTemplate) {
|
||||||
super(jdbcTemplate);
|
super(jdbcTemplate);
|
||||||
|
indexes = new MapIndexConfig[] {
|
||||||
|
new MapIndexConfig().setAttribute("sessionId").setOrdered(false),
|
||||||
|
new MapIndexConfig().setAttribute("tradingClearingRegistryId").setOrdered(false),
|
||||||
|
new MapIndexConfig().setAttribute("companyId").setOrdered(false),
|
||||||
|
new MapIndexConfig().setAttribute("accountId").setOrdered(false),
|
||||||
|
new MapIndexConfig().setAttribute("settlementDate").setOrdered(false),
|
||||||
|
new MapIndexConfig().setAttribute("groupId").setOrdered(false),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -32,8 +43,8 @@ public class RegistryMapStore extends TemplateMapStore<Registry> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getIndexingField() {
|
public MapIndexConfig[] getIndexes() {
|
||||||
return new String[]{"sessionId"};
|
return indexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,14 @@ public class PoolMapConfigs implements InitializingBean {
|
||||||
}
|
}
|
||||||
existMapStores.add(mapStore.getMapName()); // IMDGDistributedNames
|
existMapStores.add(mapStore.getMapName()); // IMDGDistributedNames
|
||||||
MapConfig mapCfg = makeDefaultMapConfig(mapStore.getMapName(), mapStore);
|
MapConfig mapCfg = makeDefaultMapConfig(mapStore.getMapName(), mapStore);
|
||||||
if (mapStore.getIndexingField() != null && mapStore.getIndexingField().length > 0) {
|
if (mapStore.getIndexes().length > 0) {
|
||||||
|
if (log.isTraceEnabled()) {
|
||||||
|
log.trace("Create indexing filed on {}: {}", mapStore.getMapName(), Arrays.toString(mapStore.getIndexes()));
|
||||||
|
}
|
||||||
|
for (MapIndexConfig index : mapStore.getIndexes()) {
|
||||||
|
mapCfg.addMapIndexConfig(index);
|
||||||
|
}
|
||||||
|
} else if (mapStore.getIndexingField() != null && mapStore.getIndexingField().length > 0) {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("Create indexing filed on {}: {}", mapStore.getMapName(), Arrays.toString(mapStore.getIndexingField()));
|
log.trace("Create indexing filed on {}: {}", mapStore.getMapName(), Arrays.toString(mapStore.getIndexingField()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue