1 19 package org.enhydra.dods.cache; 20 21 import java.util.Collection ; 22 import java.util.Date ; 23 import java.util.Enumeration ; 24 import java.util.HashMap ; 25 import java.util.HashSet ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 import java.util.Vector ; 29 30 import org.enhydra.dods.DODS; 31 import org.enhydra.dods.cache.base.BaseCacheManager; 32 import org.enhydra.dods.cache.base.DODSCache; 33 import org.enhydra.dods.exceptions.CacheObjectException; 34 import org.enhydra.dods.statistics.CacheStatistics; 35 import org.enhydra.dods.statistics.Statistics; 36 import org.enhydra.dods.statistics.TableStatistics; 37 38 import com.lutris.appserver.server.sql.CoreDataStruct; 39 import com.lutris.appserver.server.sql.DatabaseManagerException; 40 import com.lutris.appserver.server.sql.standard.DatabaseConfiguration; 41 import com.lutris.appserver.server.sql.standard.StandardLogicalDatabase; 42 import com.lutris.util.Config; 43 44 54 public class QueryCacheImpl extends QueryCache { 55 56 61 protected DODSCache cache = null; 62 63 69 protected DODSCache simpleQCache = null; 70 71 77 protected DODSCache complexQCache = null; 78 79 85 protected DODSCache multiJoinQCache = null; 86 87 96 protected CacheAdministration[] cacheAdministration = new CacheAdministration[4]; 97 98 102 protected TableConfiguration tableConf = new TableConfiguration(); 103 104 110 protected String initialQueryCache = null; 111 112 115 protected boolean multi = false; 116 117 120 protected boolean fullCachingOn = false; 121 122 125 protected Statistics statistics = null; 126 127 133 protected HashMap nonVisibleList = null; 134 135 141 protected int oldSimpleMaxCacheSize; 142 143 149 protected int oldComplexMaxCacheSize; 150 151 158 protected int oldMultiJoinMaxCacheSize; 159 160 172 protected double reserveFactor = CacheConstants.DEFAULT_RESERVE_FACTOR; 173 174 177 private boolean isDisabled = false; 178 179 182 private boolean isDisabledSimple = false; 183 184 187 private boolean isDisabledComplex = false; 188 189 192 private boolean isDisabledMultiJoin = false; 193 194 private double cachePercentage = CacheConstants.DEFAULT_CACHE_PERCENTAGE; 195 196 private int initialCacheFetchSize = CacheConstants.DEFAULT_INITIAL_CACHE_FETCH_SIZE; 197 198 private int initialDSCacheSize = CacheConstants.DEFAULT_INITIAL_DS_CACHE_SIZE; 199 200 204 private int disabledMaxCacheSize = 0; 205 206 209 private int disabledMaxSimpleQueryCacheSize = 0; 210 211 214 private int disabledMaxComplexQueryCacheSize = 0; 215 216 219 private int disabledMaxMultiJoinQueryCacheSize = 0; 220 221 231 public QueryCacheImpl(int maxCSize) throws CacheObjectException { 232 if (isDisabled) { 233 throw new CacheObjectException("Caching is disabled"); 234 } 235 cache = BaseCacheManager.getDODSCache(maxCSize); 236 if (cache != null) { 237 simpleQCache = BaseCacheManager.getDODSCache(CacheConstants.DEFAULT_MAX_SIMPLE_QUERY_CACHE_SIZE); 238 complexQCache = BaseCacheManager.getDODSCache(CacheConstants.DEFAULT_MAX_COMPLEX_QUERY_CACHE_SIZE); 239 multiJoinQCache = BaseCacheManager.getDODSCache(CacheConstants.DEFAULT_MAX_MULTI_JOIN_QUERY_CACHE_SIZE); 240 } 241 statistics = new QueryCacheImplStatistics(); 242 nonVisibleList = new HashMap (); 243 init(); 244 } 245 246 253 public QueryCacheImpl() throws CacheObjectException { 254 this(CacheConstants.DEFAULT_MAX_CACHE_SIZE); 255 } 256 257 271 public CacheAdministration getCacheAdministration(int cacheType) { 272 if (cacheType < 0 || cacheType > 3) { 273 return null; 274 } 275 return cacheAdministration[cacheType]; 276 } 277 278 284 public String getInitialQueryCache() { 285 return initialQueryCache; 286 } 287 288 296 protected void setInitialQueryCache(String initQ) { 297 initialQueryCache = initQ; 298 } 299 300 public void makeInvisible(String cacheHandle) { 301 if (getCacheAdministration(CacheConstants.DATA_CACHE).getMaxCacheSize() != 0) { 302 Integer intObj = (Integer ) nonVisibleList.get(cacheHandle); 303 int num; 304 305 if (intObj != null) { 306 num = intObj.intValue(); 307 num++; 308 nonVisibleList.put(cacheHandle, new Integer (num)); 309 } else { 310 nonVisibleList.put(cacheHandle, new Integer (1)); 311 } 312 } 313 } 314 315 public void makeVisible(String cacheHandle) { 316 if (getCacheAdministration(CacheConstants.DATA_CACHE).getMaxCacheSize() != 0) { 317 Integer intObj = (Integer ) nonVisibleList.get(cacheHandle); 318 int num; 319 320 if (intObj != null) { 321 num = intObj.intValue(); 322 num--; 323 if (num == 0) { 324 nonVisibleList.remove(cacheHandle); 325 } else { 326 nonVisibleList.put(cacheHandle, new Integer (num)); 327 } 328 } 329 } 330 } 331 332 337 public Statistics getStatistics() { 338 statistics.stopTime(); 339 return statistics; 340 } 341 342 345 public void refreshStatistics() { 346 statistics.clear(); 347 } 348 349 358 public void checkFull() { 359 if ((cacheAdministration[0].getMaxCacheSize() < 0) && (getInitialQueryCache() != null) 360 && (getInitialQueryCache().equalsIgnoreCase("*"))) { 361 fullCachingOn = true; 362 } else { 363 fullCachingOn = false; 364 } 365 } 366 367 376 public boolean isFull() { 377 if (fullCachingOn) { 378 checkFull(); 379 } 380 return fullCachingOn; 381 } 382 383 391 public String getCacheType() { 392 if (cacheAdministration[CacheConstants.DATA_CACHE].getMaxCacheSize() == 0) { 393 return "none"; 394 } else { 395 if (isFull()) { 396 return "full"; 397 } else { 398 return "lru"; 399 } 400 } 401 } 402 403 412 public int getLevelOfCaching() { 413 return CacheConstants.QUERY_CACHING; 414 } 415 416 422 public TableConfiguration getTableConfiguration() { 423 return tableConf; 424 } 425 426 439 public double getReserveFactor() { 440 return reserveFactor; 441 } 442 443 457 protected void setReserveFactor(double res) { 458 reserveFactor = res; 459 } 460 461 464 protected void setCachePercentage(double percent) { 465 cachePercentage = percent; 466 } 467 468 471 public double getCachePercentage() { 472 return cachePercentage; 473 } 474 475 480 public boolean isDisabled() { 481 return isDisabled; 482 } 483 484 493 public void readConfiguration(Config tableConfig, Config cacheConfig, String dbName) throws CacheObjectException { 494 if (isDisabled) { 495 throw new CacheObjectException("Caching is disabled"); 496 } 497 boolean initialAllCaches = CacheConstants.DEFAULT_INITIAL_ALL_CACHES; 498 int maxSize = CacheConstants.DEFAULT_MAX_CACHE_SIZE; 499 int maxSimple = CacheConstants.DEFAULT_MAX_SIMPLE_QUERY_CACHE_SIZE; 500 int maxComplex = CacheConstants.DEFAULT_MAX_COMPLEX_QUERY_CACHE_SIZE; 501 int maxMultiJoin = CacheConstants.DEFAULT_MAX_MULTI_JOIN_QUERY_CACHE_SIZE; 502 Config defaultCacheConfig = null; 503 504 this.tableConf.readTableConfiguration(tableConfig, dbName); 505 506 DatabaseConfiguration dbConf; 507 508 try { 509 dbConf = ((StandardLogicalDatabase) (DODS.getDatabaseManager().findLogicalDatabase(dbName))) 510 .getDatabaseConfiguration(); 511 } catch (Exception ex) { 512 throw new CacheObjectException("Error reading database configuration"); 513 } 514 if (dbConf != null) { 515 try { 516 maxSize = dbConf.getMaxCacheSize(); 517 } catch (Exception e) { 518 } 519 try { 520 maxSimple = dbConf.getMaxSimpleCacheSize(); 521 } catch (Exception e) { 522 } 523 try { 524 maxComplex = dbConf.getMaxComplexCacheSize(); 525 } catch (Exception e) { 526 } 527 try { 528 maxMultiJoin = dbConf.getMaxMultiJoinCacheSize(); 529 } catch (Exception e) { 530 } 531 try { 532 reserveFactor = dbConf.getReserveFactor(); 533 } catch (Exception e) { 534 } 535 try { 536 cachePercentage = dbConf.getCachePercentage(); 537 } catch (Exception e) { 538 } 539 try { 540 initialAllCaches = dbConf.getInitAllCaches(); 541 } catch (Exception e) { 542 } 543 try { 544 initialCacheFetchSize = dbConf.getInitialCacheFetchSize(); 545 } catch (Exception e) { 546 } 547 try { 548 initialDSCacheSize = dbConf.getInitialDSCacheSize(); 549 } catch (Exception e) { 550 } 551 552 } 553 if (cacheConfig != null) { 554 try { 555 maxSize = cacheConfig.getInt(CacheConstants.PARAMNAME_MAX_CACHE_SIZE); 556 } catch (Exception e) { 557 } 558 try { 559 maxSimple = cacheConfig.getInt(CacheConstants.PARAMNAME_MAX_SIMPLE_CACHE_SIZE); 560 } catch (Exception e) { 561 } 562 try { 563 maxComplex = cacheConfig.getInt(CacheConstants.PARAMNAME_MAX_COMPLEX_CACHE_SIZE); 564 } catch (Exception e) { 565 } 566 try { 567 maxMultiJoin = cacheConfig.getInt(CacheConstants.PARAMNAME_MAX_MULTI_JOIN_CACHE_SIZE); 568 } catch (Exception e) { 569 } 570 try { 571 initialQueryCache = cacheConfig.getString(CacheConstants.PARAMNAME_INITIAL_CONDITION); 572 } catch (Exception e) { 573 if (initialAllCaches) { 574 initialQueryCache = "*"; 575 } 576 } 577 try { 578 reserveFactor = cacheConfig.getDouble(CacheConstants.PARAMNAME_RESERVE_FACTOR); 579 } catch (Exception e) { 580 } 581 try { 582 cachePercentage = cacheConfig.getDouble(CacheConstants.PARAMNAME_CACHE_PERCENTAGE); 583 } catch (Exception e) { 584 } 585 try { 586 initialCacheFetchSize = cacheConfig.getInt(CacheConstants.PARAMNAME_INITIAL_CACHE_FETCH_SIZE); 587 } catch (Exception e) { 588 } 589 try { 590 initialDSCacheSize = cacheConfig.getInt(CacheConstants.PARAMNAME_INITIAL_DS_CACHE_SIZE); 591 } catch (Exception e) { 592 } 593 } else { 594 if (initialAllCaches) { 595 initialQueryCache = "*"; 596 } 597 } 598 cacheAdministration[CacheConstants.DATA_CACHE].setMaxCacheSize(maxSize); 599 cacheAdministration[CacheConstants.SIMPLE_QUERY_CACHE].setMaxCacheSize(maxSimple); 600 cacheAdministration[CacheConstants.COMPLEX_QUERY_CACHE].setMaxCacheSize(maxComplex); 601 cacheAdministration[CacheConstants.MULTI_JOIN_QUERY_CACHE].setMaxCacheSize(maxMultiJoin); 602 } 603 604 609 public DataStructCache newInstance() throws CacheObjectException { 610 if (isDisabled) { 611 throw new CacheObjectException("Caching is disabled"); 612 } 613 return new QueryCacheImpl(); 614 } 615 616 623 protected void init() { 624 cacheAdministration[CacheConstants.SIMPLE_QUERY_CACHE] = new CacheAdministration() { 625 626 631 public int getMaxCacheSize() { 632 if (simpleQCache != null) { 633 return simpleQCache.getMaxEntries(); 634 } 635 return 0; 636 } 637 638 649 public int getMaxCacheSize(boolean real) { 650 int size = getMaxCacheSize(); 651 652 if (size < 0) { 653 if (real) { 654 return -1; 655 } else { 656 return getCacheSize(); 657 } 658 } 659 return size; 660 } 661 662 668 protected void setMaxCacheSize(int maxSize) throws CacheObjectException { 669 try { 670 if (isDisabled) { 671 throw new CacheObjectException("Caching is disabled"); 672 } 673 if (maxSize == 0) { 674 if (simpleQCache != null) { 675 statistics.getCacheStatistics(CacheConstants.SIMPLE_QUERY_CACHE).clearStatistics(); 676 simpleQCache = null; 677 } 678 return; 679 } 680 if (simpleQCache == null) { 681 if (cache != null) { 682 simpleQCache = BaseCacheManager.getDODSCache(maxSize); 683 } 684 } else { 685 simpleQCache.setMaxEntries(maxSize); 686 } 687 } catch (Exception ex) { 688 System.out.println("Error in setMaxCacheSize - simple cache"); 689 } 690 } 691 692 697 public int getCacheSize() { 698 if (simpleQCache != null) { 699 return simpleQCache.size(); 700 } 701 return 0; 702 } 703 704 707 public void refresh() { 708 if (cache != null) { 709 if (simpleQCache != null) { 710 simpleQCache = BaseCacheManager.getDODSCache(simpleQCache.getMaxEntries()); 711 statistics.getCacheStatistics(CacheConstants.SIMPLE_QUERY_CACHE).setCacheHitsNum(0); 712 } 713 } 714 } 715 716 719 public void disable() { 720 if (!isDisabledSimple) { 721 isDisabledSimple = true; 722 if (simpleQCache != null) { 723 disabledMaxSimpleQueryCacheSize = simpleQCache.getMaxEntries(); 724 simpleQCache = null; 725 } else { 726 disabledMaxSimpleQueryCacheSize = 0; 727 } 728 } 729 } 730 731 734 public void enable() { 735 try { 736 if (isDisabledSimple) { 737 if (disabledMaxSimpleQueryCacheSize != 0) { 738 if (disabledMaxCacheSize != 0) { 739 simpleQCache = BaseCacheManager.getDODSCache(disabledMaxSimpleQueryCacheSize); 740 } 741 } 742 isDisabledSimple = false; 743 } 744 DODSCache obj = (DODSCache) statistics.getCacheStatistics(CacheConstants.SIMPLE_QUERY_CACHE); 745 746 if (obj != null) { 747 obj.clearStatistics(); 748 } 749 } catch (Exception ex) { 750 System.out.println("Error in enable simple"); 751 } 752 } 753 }; 754 cacheAdministration[CacheConstants.COMPLEX_QUERY_CACHE] = new CacheAdministration() { 755 756 761 public int getMaxCacheSize() { 762 if (complexQCache != null) { 763 return complexQCache.getMaxEntries(); 764 } 765 return 0; 766 } 767 768 780 public int getMaxCacheSize(boolean real) { 781 int size = getMaxCacheSize(); 782 783 if (size < 0) { 784 if (real) { 785 return -1; 786 } else { 787 return getCacheSize(); 788 } 789 } 790 return size; 791 } 792 793 799 protected void setMaxCacheSize(int maxSize) throws CacheObjectException { 800 try { 801 if (isDisabled) { 802 throw new CacheObjectException("Caching is disabled"); 803 } 804 if (maxSize == 0) { 805 if (complexQCache != null) { 806 statistics.getCacheStatistics(CacheConstants.COMPLEX_QUERY_CACHE).clearStatistics(); 807 complexQCache = null; 808 } 809 return; 810 } 811 if (complexQCache == null) { 812 if (cache != null) { 813 complexQCache = BaseCacheManager.getDODSCache(maxSize); 814 } 815 } else { 816 complexQCache.setMaxEntries(maxSize); 817 } 818 } catch (Exception ex) { 819 System.out.println("Error in setMaxCacheSize - complex cache"); 820 } 821 } 822 823 828 public int getCacheSize() { 829 if (complexQCache != null) { 830 return complexQCache.size(); 831 } 832 return 0; 833 } 834 835 838 public void refresh() { 839 if (cache != null) { 840 if (complexQCache != null) { 841 complexQCache = BaseCacheManager.getDODSCache(complexQCache.getMaxEntries()); 842 statistics.getCacheStatistics(CacheConstants.COMPLEX_QUERY_CACHE).setCacheHitsNum(0); 843 } 844 } 845 } 846 847 850 public void disable() { 851 if (!isDisabledComplex) { 852 isDisabledComplex = true; 853 if (complexQCache != null) { 854 disabledMaxComplexQueryCacheSize = complexQCache.getMaxEntries(); 855 complexQCache = null; 856 } else { 857 disabledMaxComplexQueryCacheSize = 0; 858 } 859 } 860 } 861 862 865 public void enable() { 866 try { 867 if (isDisabledComplex) { 868 if (disabledMaxComplexQueryCacheSize != 0) { 869 if (disabledMaxCacheSize != 0) { 870 complexQCache = BaseCacheManager.getDODSCache(disabledMaxComplexQueryCacheSize); 871 } 872 } 873 isDisabledComplex = false; 874 } 875 DODSCache obj = (DODSCache) statistics.getCacheStatistics(CacheConstants.COMPLEX_QUERY_CACHE); 876 877 if (obj != null) { 878 obj.clearStatistics(); 879 } 880 } catch (Exception ex) { 881 System.out.println("Error in enable complex"); 882 } 883 } 884 }; 885 886 cacheAdministration[CacheConstants.MULTI_JOIN_QUERY_CACHE] = new CacheAdministration() { 887 888 893 public int getMaxCacheSize() { 894 if (multiJoinQCache != null) { 895 return multiJoinQCache.getMaxEntries(); 896 } 897 return 0; 898 } 899 900 912 public int getMaxCacheSize(boolean real) { 913 int size = getMaxCacheSize(); 914 915 if (size < 0) { 916 if (real) { 917 return -1; 918 } else { 919 return getCacheSize(); 920 } 921 } 922 return size; 923 } 924 925 931 protected void setMaxCacheSize(int maxSize) throws CacheObjectException { 932 try { 933 if (isDisabled) { 934 throw new CacheObjectException("Caching is disabled"); 935 } 936 if (maxSize == 0) { 937 if (multiJoinQCache != null) { 938 statistics.getCacheStatistics(CacheConstants.MULTI_JOIN_QUERY_CACHE).clearStatistics(); 939 multiJoinQCache = null; 940 } 941 return; 942 } 943 if (multiJoinQCache == null) { 944 if (cache != null) { 945 multiJoinQCache = BaseCacheManager.getDODSCache(maxSize); 946 } 947 } else { 948 multiJoinQCache.setMaxEntries(maxSize); 949 } 950 } catch (Exception ex) { 951 System.out.println("Error in setMaxCacheSize - complex cache"); 952 } 953 } 954 955 960 public int getCacheSize() { 961 if (multiJoinQCache != null) { 962 return multiJoinQCache.size(); 963 } 964 return 0; 965 } 966 967 970 public void refresh() { 971 if (cache != null) { 972 if (multiJoinQCache != null) { 973 multiJoinQCache = BaseCacheManager.getDODSCache(multiJoinQCache.getMaxEntries()); 974 statistics.getCacheStatistics(CacheConstants.MULTI_JOIN_QUERY_CACHE).setCacheHitsNum(0); 975 } 976 } 977 } 978 979 982 public void disable() { 983 if (!isDisabledMultiJoin) { 984 isDisabledMultiJoin = true; 985 if (multiJoinQCache != null) { 986 disabledMaxMultiJoinQueryCacheSize = multiJoinQCache.getMaxEntries(); 987 multiJoinQCache = null; 988 } else { 989 disabledMaxMultiJoinQueryCacheSize = 0; 990 } 991 } 992 } 993 994 997 public void enable() { 998 try { 999 if (isDisabledMultiJoin) { 1000 if (disabledMaxMultiJoinQueryCacheSize != 0) { 1001 if (disabledMaxCacheSize != 0) { 1002 multiJoinQCache = BaseCacheManager.getDODSCache(disabledMaxMultiJoinQueryCacheSize); 1003 } 1004 } 1005 isDisabledMultiJoin = false; 1006 } 1007 DODSCache obj = (DODSCache) statistics.getCacheStatistics(CacheConstants.MULTI_JOIN_QUERY_CACHE); 1008 1009 if (obj != null) { 1010 obj.clearStatistics(); 1011 } 1012 } catch (Exception ex) { 1013 System.out.println("Error in enable complex"); 1014 } 1015 } 1016 }; 1017 1018 cacheAdministration[CacheConstants.DATA_CACHE] = new CacheAdministration() { 1019 1020 1025 public int getMaxCacheSize() { 1026 if (cache != null) { 1027 return cache.getMaxEntries(); 1028 } 1029 return 0; 1030 } 1031 1032 1044 public int getMaxCacheSize(boolean real) { 1045 int size = getMaxCacheSize(); 1046 1047 if (size < 0) { 1048 if (real) { 1049 return -1; 1050 } else { 1051 return getCacheSize(); 1052 } 1053 } 1054 return size; 1055 } 1056 1057 1062 public int getCacheSize() { 1063 if (cache != null) { 1064 return cache.size(); 1065 } 1066 return 0; 1067 } 1068 1069 1075 protected void setMaxCacheSize(int maxSize) throws CacheObjectException { 1076 try { 1077 if (isDisabled) { 1078 throw new CacheObjectException("Caching is disabled"); 1079 } 1080 if (maxSize == 0) { 1081 cache = null; 1082 if (simpleQCache != null) { 1083 oldSimpleMaxCacheSize = getCacheAdministration(CacheConstants.SIMPLE_QUERY_CACHE) 1084 .getMaxCacheSize(); 1085 simpleQCache = null; 1086 } else { 1087 oldSimpleMaxCacheSize = 0; 1088 } 1089 if (complexQCache != null) { 1090 oldComplexMaxCacheSize = getCacheAdministration(CacheConstants.COMPLEX_QUERY_CACHE) 1091 .getMaxCacheSize(); 1092 complexQCache = null; 1093 } else { 1094 oldComplexMaxCacheSize = 0; 1095 } 1096 if (multiJoinQCache != null) { 1097 oldMultiJoinMaxCacheSize = getCacheAdministration(CacheConstants.MULTI_JOIN_QUERY_CACHE) 1098 .getMaxCacheSize(); 1099 multiJoinQCache = null; 1100 } else { 1101 oldMultiJoinMaxCacheSize = 0; 1102 } 1103 statistics.clear(); 1104 return; 1105 } 1106 if (cache == null) { 1107 cache = BaseCacheManager.getDODSCache(maxSize); 1108 if (oldSimpleMaxCacheSize != 0) { 1109 simpleQCache = BaseCacheManager.getDODSCache(oldSimpleMaxCacheSize); 1110 } 1111 if (oldComplexMaxCacheSize != 0) { 1112 complexQCache = BaseCacheManager.getDODSCache(oldComplexMaxCacheSize); 1113 } 1114 if (oldMultiJoinMaxCacheSize != 0) { 1115 multiJoinQCache = BaseCacheManager.getDODSCache(oldMultiJoinMaxCacheSize); 1116 } 1117 } else { 1118 cache.setMaxEntries(maxSize); 1119 } 1120 } catch (Exception ex) { 1121 System.out.println("Error in setMaxCacheSize - DO cache"); 1122 } 1123 } 1124 1125 1129 public void refresh() { 1130 if (cache != null) { 1131 cache = BaseCacheManager.getDODSCache(cache.getMaxEntries()); 1132 } 1133 if (simpleQCache != null) { 1134 simpleQCache = BaseCacheManager.getDODSCache(simpleQCache.getMaxEntries()); 1135 } 1136 if (complexQCache != null) { 1137 complexQCache = BaseCacheManager.getDODSCache(complexQCache.getMaxEntries()); 1138 } 1139 if (multiJoinQCache != null) { 1140 multiJoinQCache = BaseCacheManager.getDODSCache(multiJoinQCache.getMaxEntries()); 1141 } 1142 statistics.clear(); 1143 } 1144 1145 1149 public void disable() { 1150 if (!isDisabled) { 1151 isDisabled = true; 1152 if (cache != null) { 1153 disabledMaxCacheSize = cache.getMaxEntries(); 1154 cache = null; 1155 if (simpleQCache != null) { 1156 getCacheAdministration(CacheConstants.SIMPLE_QUERY_CACHE).disable(); 1157 } 1158 if (complexQCache != null) { 1159 cacheAdministration[CacheConstants.COMPLEX_QUERY_CACHE].disable(); 1160 } 1161 if (multiJoinQCache != null) { 1162 cacheAdministration[CacheConstants.MULTI_JOIN_QUERY_CACHE].disable(); 1163 } 1164 statistics.clear(); 1165 } 1166 } 1167 } 1168 1169 1174 public void enable() { 1175 try { 1176 if (isDisabled) { 1177 if (disabledMaxCacheSize != 0) { 1178 cache = BaseCacheManager.getDODSCache(disabledMaxCacheSize); 1179 } 1180 if (isDisabledSimple) { 1181 getCacheAdministration(CacheConstants.SIMPLE_QUERY_CACHE).enable(); 1182 } 1183 if (isDisabledComplex) { 1184 getCacheAdministration(CacheConstants.COMPLEX_QUERY_CACHE).enable(); 1185 } 1186 if (isDisabledMultiJoin) { 1187 getCacheAdministration(CacheConstants.MULTI_JOIN_QUERY_CACHE).enable(); 1188 } 1189 statistics.clear(); 1190 isDisabled = false; 1191 } 1192 } catch (Exception ex) { 1193 System.out.println("Error in enable DO"); 1194 } 1195 } 1196 }; 1197 } 1198 1199 1205 public Map getCacheContent() { 1206 return cache; 1207 } 1208 1209 1214 public boolean isMulti() { 1215 return multi; 1216 } 1217 1218 1223 public boolean toReconfigure() { 1224 return false; 1225 } 1226 1227 1235 public CoreDataStruct addDataStruct(CoreDataStruct newDS) { 1236 String handle; 1237 try { 1238 handle = newDS.get_CacheHandle(); 1239 } catch (Exception e) { 1240 handle = null; 1241 } 1242 if (cache == null) { 1243 return newDS; 1244 } 1245 try { 1246 if (null != handle) { 1247 synchronized (cache) { 1248 cache.add(handle, newDS); 1249 } 1250 return newDS; 1251 } 1252 } catch (Exception e) { 1253 e.printStackTrace(); 1254 } 1255 return null; 1256 } 1257 1258 1267 public CoreDataStruct removeDataStruct(CoreDataStruct data) { 1268 try { 1269 String handle = data.get_CacheHandle(); 1270 if (cache != null) { 1271 synchronized (cache) { 1272 return (CoreDataStruct) cache.remove(handle); 1273 } 1274 } 1275 } catch (Exception e) { 1276 } 1277 return null; 1278 } 1279 1280 1291 public CoreDataStruct removeDataStruct(String handle) { 1292 if (cache != null) { 1293 synchronized (cache) { 1294 try { 1295 return (CoreDataStruct) cache.remove(handle); 1296 } catch (Exception e) { 1297 } 1298 } 1299 } 1300 return null; 1301 } 1302 1303 1313 public CoreDataStruct updateDataStruct(CoreDataStruct data) { 1314 try { 1315 data = addDataStruct(data); 1316 QueryCacheItem queryItem = null; 1317 HashSet del; 1318 Iterator iter = null; 1319 1320 if (complexQCache != null) { 1321 del = new HashSet (); 1322 synchronized (complexQCache) { 1323 for (iter = complexQCache.values().iterator(); iter.hasNext();) { 1324 queryItem = (QueryCacheItem) iter.next(); 1325 if (data.get_Database().equals(queryItem.get_OriginDatabase())) { 1326 del.add(queryItem); 1327 } 1328 } 1329 } iter = null; 1331 for (iter = del.iterator(); iter.hasNext();) { 1332 removeComplexQuery((QueryCacheItem) iter.next()); 1333 } 1334 } 1335 if (multiJoinQCache != null) { 1336 del = new HashSet (); 1337 synchronized (multiJoinQCache) { 1338 for (iter = multiJoinQCache.values().iterator(); iter.hasNext();) { 1339 queryItem = (QueryCacheItem) iter.next(); 1340 if (data.get_Database().equals(queryItem.get_OriginDatabase())) { 1341 del.add(queryItem); 1342 } 1343 } 1344 } iter = null; 1346 for (iter = del.iterator(); iter.hasNext();) { 1347 removeMultiJoinQuery((QueryCacheItem) iter.next()); 1348 } 1349 } 1350 if (simpleQCache != null) { 1351 iter = null; 1352 synchronized (simpleQCache) { 1353 for (iter = simpleQCache.values().iterator(); iter.hasNext();) { 1354 queryItem = (QueryCacheItem) iter.next(); 1355 String db = data.get_Database(); 1356 1357 if (db.equals(queryItem.get_OriginDatabase())) { 1358 if (queryItem.checkConditions(data)) { 1359 if (queryItem.getOIds().contains(data.get_Handle())) { 1360 queryItem.setModifiedQuery(true); 1361 } else { 1362 if (queryItem.isCompleteResult()) { 1363 queryItem.add(data); 1364 } 1365 queryItem.setModifiedQuery(true); 1366 1367 } 1368 } else { 1370 if (queryItem.getOIds().contains(data.get_Handle())) { 1371 queryItem.delete(data); 1372 queryItem.setModifiedQuery(true); 1373 } 1374 } } } } } } catch (DatabaseManagerException ex) { 1380 } 1381 return data; 1382 } 1383 1384 1393 public CoreDataStruct deleteDataStruct(CoreDataStruct data) { 1394 if (data != null) { 1395 CoreDataStruct oldDS = removeDataStruct(data); 1396 Iterator iter = null; 1397 QueryCacheItem queryItem = null; 1398 1399 if (simpleQCache != null) { 1400 synchronized (simpleQCache) { 1401 for (iter = simpleQCache.values().iterator(); iter.hasNext();) { 1402 queryItem = (QueryCacheItem) iter.next(); 1403 try { 1404 String db = data.get_Database(); 1405 1406 if (db.equals(queryItem.get_OriginDatabase())) { 1407 if (queryItem.getOIds().contains(data.get_Handle())) { 1408 queryItem.delete(data); 1409 queryItem.setModifiedQuery(true); 1410 } 1411 } 1412 } catch (Exception e) { 1413 System.out.println("Error in deleteDataStruct of QueryCacheImpl"); 1414 } 1415 } 1416 } } 1418 iter = null; 1419 if (complexQCache != null) { 1420 synchronized (complexQCache) { 1421 for (iter = complexQCache.values().iterator(); iter.hasNext();) { 1422 queryItem = (QueryCacheItem) iter.next(); 1423 try { 1424 String db = data.get_Database(); 1425 1426 if (db.equals(queryItem.get_OriginDatabase())) { 1427 if (queryItem.getOIds().contains(data.get_Handle())) { 1428 queryItem.delete(data); 1429 queryItem.setModifiedQuery(true); 1430 } 1431 } 1432 } catch (Exception e) { 1433 System.out.println("Error in deleteDataStruct of QueryCacheImpl"); 1434 } 1435 } 1436 } } 1438 if (multiJoinQCache != null) { 1439 synchronized (multiJoinQCache) { 1440 for (iter = multiJoinQCache.values().iterator(); iter.hasNext();) { 1441 queryItem = (QueryCacheItem) iter.next(); 1442 try { 1443 String db = data.get_Database(); 1444 1445 if (db.equals(queryItem.get_OriginDatabase())) { 1446 if (queryItem.getOIds().contains(data.get_Handle())) { 1447 queryItem.delete(data); 1448 queryItem.setModifiedQuery(true); 1449 } 1450 } 1451 } catch (Exception e) { 1452 System.out.println("Error in deleteDataStruct of QueryCacheImpl"); 1453 } 1454 } 1455 } } 1457 return oldDS; 1458 } 1459 return null; 1460 } 1461 1462 1472 public CoreDataStruct getDataStructByHandle(String cacheHandle) { 1473 if (cache == null) { 1474 return null; 1475 } 1476 if (isLocked()) { 1477 return null; 1478 } 1479 CoreDataStruct tmpDO = null; 1480 if(cache.isNeedToSynchronize()) { 1481 synchronized (cache) { 1482 tmpDO = getCacheItem(cacheHandle, tmpDO); 1483 } 1484 }else { 1485 tmpDO = getCacheItem(cacheHandle, tmpDO); 1486 } 1487 return tmpDO; 1488 } 1489 1490 1495 private CoreDataStruct getCacheItem(String cacheHandle, CoreDataStruct tmpDO) { 1496 cache.incrementCacheAccessNum(1); 1497 if (!nonVisibleList.containsKey(cacheHandle)) { 1498 tmpDO = (CoreDataStruct) cache.get(cacheHandle); 1499 if (tmpDO != null) { 1500 cache.incrementCacheHitsNum(1); 1501 } 1502 } 1503 return tmpDO; 1504 } 1505 1506 1513 public QueryCacheItem newQueryCacheItemInstance(String dbName) { 1514 return new QueryCacheItemImpl(dbName); 1515 } 1516 1517 1527 public QueryCacheItem getSimpleQueryCacheItem(String dbName, String query) { 1528 if (simpleQCache != null && !isLockedSimpleComplexQCache()) { 1529 return _getItem(simpleQCache, dbName + "." + query); 1530 } 1531 return null; 1532 } 1533 1534 private QueryCacheItem _getItem(DODSCache whereFrom, String whichOne) { 1535 if(whereFrom.isNeedToSynchronize()) { 1536 synchronized (whereFrom) { 1537 return (QueryCacheItem) whereFrom.get(whichOne); 1538 } 1539 } else { 1540 return (QueryCacheItem) whereFrom.get(whichOne); 1541 } 1542 } 1543 1553 public QueryCacheItem getComplexQueryCacheItem(String dbName, String query) { 1554 if (complexQCache != null && !isLockedSimpleComplexQCache()) { 1555 return _getItem(complexQCache, dbName + "." + query); 1556 } 1557 return null; 1558 } 1559 1560 1570 public QueryCacheItem getMultiJoinQueryCacheItem(String dbName, String query) { 1571 if (multiJoinQCache != null && !isLockedMultiJoinQCache()) { 1572 return _getItem(multiJoinQCache, dbName + "." + query); 1573 } 1574 return null; 1575 } 1576 1577 1584 public QueryCacheItem addSimpleQuery(QueryCacheItem queryItem) { 1585 if (simpleQCache != null) { 1586 synchronized (simpleQCache) { 1587 return (QueryCacheItem) simpleQCache.add(queryItem.get_OriginDatabase() + "." + queryItem.getQueryId(), 1588 queryItem); 1589 } 1590 } 1591 return null; 1592 } 1593 1594 1601 public QueryCacheItem removeSimpleQuery(QueryCacheItem queryItem) { 1602 if (simpleQCache != null) { 1603 synchronized (simpleQCache) { 1604 return (QueryCacheItem) simpleQCache.remove(queryItem.get_OriginDatabase() + "." 1605 + queryItem.getQueryId()); 1606 } 1607 } 1608 return null; 1609 } 1610 1611 1618 public QueryCacheItem addComplexQuery(QueryCacheItem queryItem) { 1619 if (complexQCache != null) { 1620 synchronized (complexQCache) { 1621 return (QueryCacheItem) complexQCache.add( 1622 queryItem.get_OriginDatabase() + "." + queryItem.getQueryId(), queryItem); 1623 } 1624 } 1625 return null; 1626 } 1627 1628 1635 public QueryCacheItem removeComplexQuery(QueryCacheItem queryItem) { 1636 if (complexQCache != null) { 1637 synchronized (complexQCache) { 1638 return (QueryCacheItem) complexQCache.remove(queryItem.get_OriginDatabase() + "." 1639 + queryItem.getQueryId()); 1640 } 1641 } 1642 return null; 1643 } 1644 1645 1652 public QueryCacheItem addMultiJoinQuery(QueryCacheItem queryItem) { 1653 if (multiJoinQCache != null) { 1654 synchronized (multiJoinQCache) { 1655 return (QueryCacheItem) multiJoinQCache.add(queryItem.get_OriginDatabase() + "." 1656 + queryItem.getQueryId(), queryItem); 1657 } 1658 } 1659 return null; 1660 } 1661 1662 1669 public QueryCacheItem removeMultiJoinQuery(QueryCacheItem queryItem) { 1670 if (multiJoinQCache != null) { 1671 synchronized (multiJoinQCache) { 1672 return (QueryCacheItem) multiJoinQCache.remove(queryItem.get_OriginDatabase() + "." 1673 + queryItem.getQueryId()); 1674 } 1675 } 1676 return null; 1677 } 1678 1679 1689 public QueryResult getSimpleQueryResults(String dbName, String query) { 1690 return getSimpleQueryResults(dbName, query, 0, 0, false); 1691 } 1692 1693 1707 public QueryResult getSimpleQueryResults(String dbName, String query, int limit, int maxdb) { 1708 return getSimpleQueryResults(dbName, query, limit, maxdb, false); 1709 } 1710 1711 1727 public QueryResult getSimpleQueryResults(String dbName, String query, int limit, int maxdb, boolean unique) { 1728 if (simpleQCache == null || isLockedSimpleComplexQCache()) { 1729 return null; 1730 } 1731 QueryResult result = null; 1732 String queryHandle = dbName + "." + query; 1733 QueryCacheItem queryItem = _getItem(simpleQCache, queryHandle); 1734 int i = 0; 1735 1736 if (queryItem != null) { 1737 synchronized (queryItem) { 1738 result = new QueryResult(); 1739 result.database = queryItem.get_OriginDatabase(); 1740 String handle = null; 1741 String cachePrefix = queryItem.get_OriginDatabase() + "."; 1742 Iterator iter = queryItem.getOIds().iterator(); 1743 1744 if (unique) { 1745 HashSet allResultOids = new HashSet (); 1746 int skippedNum = 0; 1747 1748 while ((maxdb == 0 || i < maxdb) && (iter.hasNext()) && ((limit == 0 || result.DOs.size() < limit))) { 1749 handle = (String ) iter.next(); 1750 if (allResultOids.contains(handle)) { 1751 skippedNum++; 1752 } else { 1753 allResultOids.add(handle); 1754 result.DOs.add(handle); 1755 1756 } 1757 i++; 1758 } result.skippedUnique = skippedNum; 1760 } else { 1762 while ((maxdb == 0 || i < maxdb) && (iter.hasNext()) && ((limit == 0 || result.DOs.size() < limit))) { 1763 handle = (String ) iter.next(); 1764 result.DOs.add(handle); 1765 i++; 1766 } } } } 1770 if (result.DOs.size() < limit) { 1771 if ((maxdb == 0) || (i < maxdb)) { 1772 result = null; 1773 } 1774 } 1775 return result; 1776 } 1777 1778 1788 public QueryResult getComplexQueryResults(String dbName, String query) { 1789 return getComplexQueryResults(dbName, query, 0, 0, false); 1790 } 1791 1792 1806 public QueryResult getComplexQueryResults(String dbName, String query, int limit, int maxdb) { 1807 return getComplexQueryResults(dbName, query, limit, maxdb, false); 1808 } 1809 1810 1826 public QueryResult getComplexQueryResults(String dbName, String query, int limit, int maxdb, boolean unique) { 1827 if (complexQCache == null || isLockedSimpleComplexQCache()) { 1828 return null; 1829 } 1830 QueryResult result = null; 1831 String queryHandle = dbName + "." + query; 1832 QueryCacheItem queryItem = _getItem(complexQCache, queryHandle); 1833 int i = 0; 1834 1835 if (queryItem != null) { 1836 synchronized (queryItem) { 1837 result = new QueryResult(); 1838 result.database = queryItem.get_OriginDatabase(); 1839 String handle = null; 1840 String cachePrefix = queryItem.get_OriginDatabase() + "."; 1841 Iterator iter = queryItem.getOIds().iterator(); 1842 1843 if (unique) { 1844 HashSet allResultOids = new HashSet (); 1845 int skippedNum = 0; 1846 1847 while ((maxdb == 0 || i < maxdb) && (iter.hasNext()) && ((limit == 0 || result.DOs.size() < limit))) { 1848 handle = (String ) iter.next(); 1849 if (allResultOids.contains(handle)) { 1850 skippedNum++; 1851 } else { 1852 allResultOids.add(handle); 1853 result.DOs.add(handle); 1854 } 1855 i++; 1856 } result.skippedUnique = skippedNum; 1858 } else { 1860 while ((maxdb == 0 || i < maxdb) && (iter.hasNext()) && ((limit == 0 || result.DOs.size() < limit))) { 1861 handle = (String ) iter.next(); 1862 result.DOs.add(handle); 1863 i++; 1864 } } } 1867 } if (result.DOs.size() < limit) { 1869 if ((maxdb == 0) || (i < maxdb)) { 1870 result = null; 1871 } 1872 } 1873 return result; 1874 } 1875 1876 1887 public QueryResult getMultiJoinQueryResults(String dbName, String query) { 1888 return getMultiJoinQueryResults(dbName, query, 0, 0, false); 1889 } 1890 1891 1906 public QueryResult getMultiJoinQueryResults(String dbName, String query, int limit, int maxdb) { 1907 return getMultiJoinQueryResults(dbName, query, limit, maxdb, false); 1908 } 1909 1910 1927 public QueryResult getMultiJoinQueryResults(String dbName, String query, int limit, int maxdb, boolean unique) { 1928 if (multiJoinQCache == null || isLockedMultiJoinQCache()) { 1929 return null; 1930 } 1931 QueryResult result = null; 1932 String queryHandle = dbName + "." + query; 1933 QueryCacheItem queryItem = _getItem(multiJoinQCache, queryHandle); 1934 int i = 0; 1935 1936 if (queryItem != null) { 1937 synchronized (queryItem) { 1938 result = new QueryResult(); 1939 result.database = queryItem.get_OriginDatabase(); 1940 String handle = null; 1941 String cachePrefix = queryItem.get_OriginDatabase() + "."; 1942 Iterator iter = queryItem.getOIds().iterator(); 1943 1944 if (unique) { 1945 HashSet allResultOids = new HashSet (); 1946 int skippedNum = 0; 1947 1948 while ((maxdb == 0 || i < maxdb) && (iter.hasNext()) && ((limit == 0 || result.DOs.size() < limit))) { 1949 handle = (String ) iter.next(); 1950 if (allResultOids.contains(handle)) { 1951 skippedNum++; 1952 } else { 1953 allResultOids.add(handle); 1954 result.DOs.add(handle); 1955 } 1956 i++; 1957 } result.skippedUnique = skippedNum; 1959 } else { 1961 while ((maxdb == 0 || i < maxdb) && (iter.hasNext()) && ((limit == 0 || result.DOs.size() < limit))) { 1962 handle = (String ) iter.next(); 1963 result.DOs.add(handle); 1964 i++; 1965 } } } 1968 } if (result.DOs.size() < limit) { 1970 if ((maxdb == 0) || (i < maxdb)) { 1971 result = null; 1972 } 1973 } 1974 return result; 1975 } 1976 1977 1989 public QueryResult getQueryResults(String dbName, String query) { 1990 QueryResult result = getSimpleQueryResults(dbName, query); 1991 1992 if (result == null) { 1993 result = getComplexQueryResults(dbName, query); 1994 } 1995 if (result == null) { 1996 result = getMultiJoinQueryResults(dbName, query); 1997 } 1998 return result; 1999 } 2000 2001 2005 private class QueryCacheImplStatistics extends TableStatistics { 2006 2007 2010 public QueryCacheImplStatistics() { 2011 try { 2012 this.reset(); 2013 if (cache != null) { 2014 getCacheStatistics(CacheConstants.DATA_CACHE).clearStatistics(); 2015 } 2016 if (simpleQCache != null) { 2017 getCacheStatistics(CacheConstants.SIMPLE_QUERY_CACHE).clearStatistics(); 2018 } 2019 if (complexQCache != null) { 2020 getCacheStatistics(CacheConstants.COMPLEX_QUERY_CACHE).clearStatistics(); 2021 } 2022 if (multiJoinQCache != null) { 2023 getCacheStatistics(CacheConstants.MULTI_JOIN_QUERY_CACHE).clearStatistics(); 2024 } 2025 } catch (Exception ex) { 2026 } 2027 } 2028 2029 2032 public void reset() { 2033 insertNum = 0; 2034 updateNum = 0; 2035 deleteNum = 0; 2036 lazyLoadingNum = 0; 2037 startTime = new Date (); 2038 stopTime = new Date (); 2039 queryNum = 0; 2040 queryByOIdNum = 0; 2041 averageQueryTime = 0; 2042 averageQueryByOIdTime = 0; 2043 } 2044 2045 2051 public int getStatisticsType() { 2052 return QUERY_CACHE_STATISTICS; 2053 } 2054 2055 2058 public void clear() { 2059 this.reset(); 2060 if (cache != null) { 2061 getCacheStatistics(CacheConstants.DATA_CACHE).clearStatistics(); 2062 } 2063 if (simpleQCache != null) { 2064 getCacheStatistics(CacheConstants.SIMPLE_QUERY_CACHE).clearStatistics(); 2065 } 2066 if (complexQCache != null) { 2067 getCacheStatistics(CacheConstants.COMPLEX_QUERY_CACHE).clearStatistics(); 2068 } 2069 if (multiJoinQCache != null) { 2070 getCacheStatistics(CacheConstants.MULTI_JOIN_QUERY_CACHE).clearStatistics(); 2071 } 2072 } 2073 2074 2092 public CacheStatistics getCacheStatistics(int type) { 2093 switch (type) { 2094 case CacheConstants.DATA_CACHE: 2095 return cache; 2096 2097 case CacheConstants.SIMPLE_QUERY_CACHE: 2098 return simpleQCache; 2099 2100 case CacheConstants.COMPLEX_QUERY_CACHE: 2101 return complexQCache; 2102 2103 case CacheConstants.MULTI_JOIN_QUERY_CACHE: 2104 return multiJoinQCache; 2105 2106 default: 2107 return null; 2108 } 2109 } 2110 } 2111 2112 2115 public String toString() { 2116 StringBuffer ret = new StringBuffer (); 2117 2118 ret.append("\n QueryCacheImpl: "); 2119 ret.append("\n cache: " + cache); 2120 ret.append("\n simpleQCache : " + simpleQCache); 2121 ret.append("\n complexQCache : " + complexQCache); 2122 ret.append("\n multiJoinQCache : " + multiJoinQCache); 2123 ret.append("\n cacheReadOnly : " + tableConf.isReadOnly()); 2124 ret.append("\n initialQueryCache : " + initialQueryCache); 2125 ret.append("\n fullCaching : " + isFull()); 2126 return ret.toString(); 2127 } 2128 2129 public void removeEntries(Vector vec) { 2130 _refreshSimpleQuery(); 2132 _refreshComplexQuery(); 2133 _refreshMultiJoinQuery(); 2134 2135 if (cache.size() > vec.size()) { 2136 for (Enumeration e = vec.elements(); e.hasMoreElements();) { 2137 removeDataStruct((String ) e.nextElement()); 2138 } 2139 } else { 2140 Iterator it = cache.values().iterator(); 2141 Vector vecToRemove = new Vector (); 2142 while (it.hasNext()) { 2143 CoreDataStruct obj = (CoreDataStruct) it.next(); 2144 try { 2145 if (vec.contains((obj.get_CacheHandle()))) 2146 vecToRemove.add(obj); 2147 } catch (DatabaseManagerException e) { 2148 } 2149 } 2150 for (Enumeration e = vecToRemove.elements(); e.hasMoreElements();) { 2151 removeDataStruct((String ) e.nextElement()); 2152 } 2153 } 2154 } 2155 2156 public void removeEntries() { 2157 _refreshSimpleQuery(); 2159 _refreshComplexQuery(); 2160 _refreshMultiJoinQuery(); 2161 2162 if (cache != null) 2163 synchronized (cache) { 2164 cache.clear(); 2165 cache.clearStatistics(); 2166 } 2168 } 2169 2170 public void emptyEntries(Vector vec, boolean incrementVersion) { 2171 _refreshSimpleQuery(); 2173 _refreshComplexQuery(); 2174 _refreshMultiJoinQuery(); 2175 2176 for (Enumeration e = vec.elements(); e.hasMoreElements();) { 2177 String cacheHandle = (String ) e.nextElement(); 2178 CoreDataStruct ds = (CoreDataStruct) cache.get(cacheHandle); 2179 if (ds != null) { 2180 updateDataStruct(ds.dumpData(incrementVersion)); 2181 } 2182 } 2183 } 2184 2185 public void emptyEntries() { 2186 _refreshSimpleQuery(); 2188 _refreshComplexQuery(); 2189 _refreshMultiJoinQuery(); 2190 2191 Collection c = cache.values(); 2192 Iterator it = c.iterator(); 2193 while (it.hasNext()) { 2194 CoreDataStruct ds = (CoreDataStruct) it.next(); 2195 updateDataStruct(ds.dumpData(false)); 2196 } 2197 } 2198 2199 private void _refreshSimpleQuery() { 2200 if (simpleQCache != null) 2201 synchronized (simpleQCache) { 2202 simpleQCache.clear(); 2203 simpleQCache.clearStatistics(); 2204 } 2207 } 2208 2209 private void _refreshComplexQuery() { 2210 if (complexQCache != null) 2211 synchronized (complexQCache) { 2212 complexQCache.clear(); 2213 complexQCache.clearStatistics(); 2214 } 2217 } 2218 2219 private void _refreshMultiJoinQuery() { 2220 if (multiJoinQCache != null) 2221 synchronized (multiJoinQCache) { 2222 multiJoinQCache.clear(); 2223 multiJoinQCache.clearStatistics(); 2224 } 2227 } 2228 2229 2232 public int getInitialCacheFetchSize() { 2233 return initialCacheFetchSize; 2234 } 2235 2236 2239 public int getInitialDSCacheSize() { 2240 return initialDSCacheSize; 2241 } 2242 2243 2246 public void setInitialCacheFetchSize(int i) { 2247 initialCacheFetchSize = i; 2248 } 2249 2250 2253 public void setInitialDSCacheSize(int i) { 2254 initialDSCacheSize = i; 2255 } 2256 2257} | Popular Tags |