public void forgetSecGroupIncludeByIncludeIdx(long ClusterId, int IncludeGroupId) { if (indexByIncludeIdx == null) { return; } CFGenKbSecGroupIncludeByIncludeIdxKey key = schema.getBackingStore().getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); if (indexByIncludeIdx.containsKey(key)) { Map<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj> mapIncludeIdx = indexByIncludeIdx.get(key); if (mapIncludeIdx != null) { List<ICFGenKbSecGroupIncludeObj> toForget = new LinkedList<ICFGenKbSecGroupIncludeObj>(); ICFGenKbSecGroupIncludeObj cur = null; Iterator<ICFGenKbSecGroupIncludeObj> iter = mapIncludeIdx.values().iterator(); while (iter.hasNext()) { cur = iter.next(); toForget.add(cur); } iter = toForget.iterator(); while (iter.hasNext()) { cur = iter.next(); cur.forget(true); } } indexByIncludeIdx.remove(key); } }
public void minimizeMemory() { allSecGroupInclude = null; indexByClusterIdx = null; indexByGroupIdx = null; indexByIncludeIdx = null; indexByUIncludeIdx = null; List<ICFGenKbSecGroupIncludeObj> toForget = new LinkedList<ICFGenKbSecGroupIncludeObj>(); ICFGenKbSecGroupIncludeObj cur = null; Iterator<ICFGenKbSecGroupIncludeObj> iter = members.values().iterator(); while (iter.hasNext()) { cur = iter.next(); if (cur.getEdit() == null) { toForget.add(cur); } } iter = toForget.iterator(); while (iter.hasNext()) { cur = iter.next(); cur.forget(); } }
public void deleteSecGroupIncludeByGroupIdx(long ClusterId, int SecGroupId) { CFGenKbSecGroupIncludeByGroupIdxKey key = schema.getBackingStore().getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); if (indexByGroupIdx == null) { indexByGroupIdx = new HashMap< CFGenKbSecGroupIncludeByGroupIdxKey, Map<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj>>(); } if (indexByGroupIdx.containsKey(key)) { Map<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj> dict = indexByGroupIdx.get(key); schema .getBackingStore() .getTableSecGroupInclude() .deleteSecGroupIncludeByGroupIdx(schema.getAuthorization(), ClusterId, SecGroupId); Iterator<ICFGenKbSecGroupIncludeObj> iter = dict.values().iterator(); ICFGenKbSecGroupIncludeObj obj; List<ICFGenKbSecGroupIncludeObj> toForget = new LinkedList<ICFGenKbSecGroupIncludeObj>(); while (iter.hasNext()) { obj = iter.next(); toForget.add(obj); } iter = toForget.iterator(); while (iter.hasNext()) { obj = iter.next(); obj.forget(true); } indexByGroupIdx.remove(key); } else { schema .getBackingStore() .getTableSecGroupInclude() .deleteSecGroupIncludeByGroupIdx(schema.getAuthorization(), ClusterId, SecGroupId); } }
public List<ICFGenKbSecGroupIncludeObj> readSecGroupIncludeByIncludeIdx( long ClusterId, int IncludeGroupId, boolean forceRead) { final String S_ProcName = "readSecGroupIncludeByIncludeIdx"; CFGenKbSecGroupIncludeByIncludeIdxKey key = schema.getBackingStore().getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); Map<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj> dict; if (indexByIncludeIdx == null) { indexByIncludeIdx = new HashMap< CFGenKbSecGroupIncludeByIncludeIdxKey, Map<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj>>(); } if ((!forceRead) && indexByIncludeIdx.containsKey(key)) { dict = indexByIncludeIdx.get(key); } else { dict = new HashMap<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj>(); // Allow other threads to dirty-read while we're loading indexByIncludeIdx.put(key, dict); ICFGenKbSecGroupIncludeObj obj; CFGenKbSecGroupIncludeBuff[] buffList = schema .getBackingStore() .getTableSecGroupInclude() .readDerivedByIncludeIdx(schema.getAuthorization(), ClusterId, IncludeGroupId); CFGenKbSecGroupIncludeBuff buff; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = schema.getSecGroupIncludeTableObj().newInstance(); obj.setPKey(schema.getBackingStore().getFactorySecGroupInclude().newPKey()); obj.setBuff(buff); ICFGenKbSecGroupIncludeObj realized = (ICFGenKbSecGroupIncludeObj) obj.realize(); } } Comparator<ICFGenKbSecGroupIncludeObj> cmp = new Comparator<ICFGenKbSecGroupIncludeObj>() { public int compare(ICFGenKbSecGroupIncludeObj lhs, ICFGenKbSecGroupIncludeObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFGenKbSecGroupIncludePKey lhsPKey = lhs.getPKey(); CFGenKbSecGroupIncludePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = dict.size(); ICFGenKbSecGroupIncludeObj arr[] = new ICFGenKbSecGroupIncludeObj[len]; Iterator<ICFGenKbSecGroupIncludeObj> valIter = dict.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFGenKbSecGroupIncludeObj> arrayList = new ArrayList<ICFGenKbSecGroupIncludeObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFGenKbSecGroupIncludeObj> sortedList = arrayList; return (sortedList); }
public List<ICFGenKbSecGroupIncludeObj> readAllSecGroupInclude(boolean forceRead) { final String S_ProcName = "readAllSecGroupInclude"; if ((allSecGroupInclude == null) || forceRead) { Map<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj> map = new HashMap<CFGenKbSecGroupIncludePKey, ICFGenKbSecGroupIncludeObj>(); allSecGroupInclude = map; CFGenKbSecGroupIncludeBuff[] buffList = schema .getBackingStore() .getTableSecGroupInclude() .readAllDerived(schema.getAuthorization()); CFGenKbSecGroupIncludeBuff buff; ICFGenKbSecGroupIncludeObj obj; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = newInstance(); obj.setPKey(schema.getBackingStore().getFactorySecGroupInclude().newPKey()); obj.setBuff(buff); ICFGenKbSecGroupIncludeObj realized = (ICFGenKbSecGroupIncludeObj) obj.realize(); } } Comparator<ICFGenKbSecGroupIncludeObj> cmp = new Comparator<ICFGenKbSecGroupIncludeObj>() { public int compare(ICFGenKbSecGroupIncludeObj lhs, ICFGenKbSecGroupIncludeObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFGenKbSecGroupIncludePKey lhsPKey = lhs.getPKey(); CFGenKbSecGroupIncludePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = allSecGroupInclude.size(); ICFGenKbSecGroupIncludeObj arr[] = new ICFGenKbSecGroupIncludeObj[len]; Iterator<ICFGenKbSecGroupIncludeObj> valIter = allSecGroupInclude.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFGenKbSecGroupIncludeObj> arrayList = new ArrayList<ICFGenKbSecGroupIncludeObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFGenKbSecGroupIncludeObj> sortedList = arrayList; return (sortedList); }