View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.docstore.process;
17  
18  import org.kuali.rice.core.api.config.property.ConfigContext;
19  import org.slf4j.Logger;
20  import org.slf4j.LoggerFactory;
21  
22  import java.util.ArrayList;
23  import java.util.HashMap;
24  import java.util.List;
25  import java.util.Map;
26  
27  /**
28   * Class to define all Process Parameters for Doc Store Processes.
29   *
30   * @author Rajesh Chowdary K
31   * @created Mar 15, 2012
32   */
33  public abstract class ProcessParameters {
34  
35      private static final Logger LOGGER = LoggerFactory.getLogger(ProcessParameters.class);
36      private static String BULK_DEFAULT_USER_IN = "webuser";
37      public static final String BULK_DEFAULT_USER = getBulkUser();
38      public static final String BULK_DEFUALT_ACTION = "bulkIngest";
39      private static final String BULK_INGEST_UPLOAD_DIR_IN = "/opt/docstore/upload/ole-batchUpload";
40      public static final String BULK_INGEST_UPLOAD_DIR = getBulkUploadDir();
41      private static final long BULK_INGEST_POLL_INTERVAL_IN = 600000;
42      public static final long BULK_INGEST_POLL_INTERVAL = getPollInterval();
43      private static final long BULK_INGEST_OPTIMIZE_SIZE_IN = 50000;
44      public static final long BULK_INGEST_COMMIT_SIZE = getCommitSize();
45      public static final long BULK_INGEST_COMMIT_SIZE_IN = 5000;
46      public static final long BULK_INGEST_OPTIMIZE_SIZE = getOptimizeSize();
47      private static final boolean BULK_INGEST_IS_LINKING_ENABLED_IN = false;
48      public static final boolean BULK_INGEST_IS_LINKING_ENABLED = getIsLinkingEnabled();
49      private static final boolean IS_UPDATE_ENABLED_IN = true;
50      public static final boolean IS_UPDATE_ENABLED = getIsUpdateEnabled();
51  
52      private static final int BULK_PROCESSOR_SPLIT_SIZE_IN = 50;
53      public static final int BULK_PROCESSOR_SPLIT_SIZE = getSplitSize();
54      private static final int BULK_PROCESSOR_THREADS_MIN_IN = 5;
55      public static final int BULK_PROCESSOR_THREADS_MIN = getBulkThreadsMin();
56      private static final int BULK_PROCESSOR_THREADS_MAX_IN = 200;
57      public static final int BULK_PROCESSOR_THREADS_MAX = getBulkThreadsMax();
58      private static final boolean BULK_PROCESSOR_MULTI_THREADED_IN = false;
59      public static final boolean BULK_PROCESSOR_MULTI_THREADED = getIsMultiThreaded();
60      public static final long BULK_PROCESSOR_TIMER_DISPLAY = 10000;
61      public static final BulkIngestTimeManager BULK_PROCESSOR_TIME_MANAGER = new BulkIngestTimeManager();
62      public static final boolean REBUILD_INDEXING_LINKING = getIsReIndexingLinkingEnabled();
63  
64      public static final long BUCKET_SIZE_LEVEL1 = 1000;
65      public static final long BUCKET_SIZE_LEVEL2 = 1000;
66      public static final long BUCKET_SIZE_LEVEL3 = 1000;
67      public static final long BUCKET_SIZE_FILE_NODES = 1000;
68  
69      public static final String NODE_LEVEL1 = "l1";
70      public static final String NODE_LEVEL2 = "l2";
71      public static final String NODE_LEVEL3 = "l3";
72      public static final String NODE_INSTANCE = "instanceNode";
73      public static final String NODE_HOLDINGS = "holdingsNode";
74      public static final String NODE_ITEM = "item";
75      public static final String FILE_MARC = "marcFile";
76      public static final String FILE_INSTANCE = "instanceFile";
77      public static final String FILE_HOLDINGS = "holdingsFile";
78      public static final String FILE_ITEM = "itemFile";
79      public static final String FILE_SOURCE_HOLDINGS = "sourceHoldingsFile";
80      public static final String FILE_PATRON_OLEML = "patronOlemlFile";
81      public static final String FILE_OLE = "olefile";
82      public static final String FILE_ONIXPL = "onixplFile";
83      public static final String FILE = "File";
84  
85      public static final List<String> STATIC_NODES = new ArrayList<String>();
86      public static final Map<String, Long> BUCKET_SIZES = new HashMap<String, Long>();
87      public static final Map<String, Boolean> HAS_REPEATED_CHILD = new HashMap<String, Boolean>();
88  
89      static {
90          STATIC_NODES.add("/work/bibliographic/marc");
91          STATIC_NODES.add("/work/bibliographic/dublin");
92          STATIC_NODES.add("/work/bibliographic/dublinunq");
93          STATIC_NODES.add("/work/instance/oleml");
94  
95          BUCKET_SIZES.put(NODE_LEVEL1, BUCKET_SIZE_LEVEL1);
96          BUCKET_SIZES.put(NODE_LEVEL2, BUCKET_SIZE_LEVEL2);
97          BUCKET_SIZES.put(NODE_LEVEL3, BUCKET_SIZE_LEVEL3);
98          BUCKET_SIZES.put(NODE_INSTANCE, BUCKET_SIZE_LEVEL3);
99  
100         HAS_REPEATED_CHILD.put(NODE_LEVEL1, true);
101         HAS_REPEATED_CHILD.put(NODE_LEVEL2, true);
102         HAS_REPEATED_CHILD.put(NODE_LEVEL3, true);
103         HAS_REPEATED_CHILD.put(NODE_INSTANCE, false);
104     }
105 
106     private static String getBulkUser() {
107         try {
108             return ConfigContext.getCurrentContextConfig().getProperty("batch.user").trim();
109         } catch (Exception e) {
110             LOGGER.error("Please set a value for \"batch.user\"", e);
111             return BULK_DEFAULT_USER_IN;
112         }
113     }
114 
115     public static String getBulkUploadDir() {
116         try {
117             return ConfigContext.getCurrentContextConfig().getProperty("batch.upload.dir").trim();
118         } catch (Exception e) {
119             LOGGER.error("Please set a value for \"batch.upload.dir\"", e);
120             return BULK_INGEST_UPLOAD_DIR_IN;
121         }
122     }
123 
124     private static int getSplitSize() {
125         try {
126             return new Integer(ConfigContext.getCurrentContextConfig().getProperty("batch.split.size").trim()).intValue();
127         } catch (Exception e) {
128             LOGGER.error("Please set a value for \"batch.split.size\"", e);
129             return BULK_PROCESSOR_SPLIT_SIZE_IN;
130         }
131     }
132 
133     private static long getPollInterval() {
134         try {
135             return (new Long(ConfigContext.getCurrentContextConfig().getProperty("batch.poll.intervel").trim()) * 60L * 1000L);
136         } catch (Exception e) {
137             LOGGER.error("Please set a value for \"batch.poll.intervel\"", e);
138             return BULK_INGEST_POLL_INTERVAL_IN;
139         }
140     }
141 
142     private static long getOptimizeSize() {
143         try {
144             return (new Long(ConfigContext.getCurrentContextConfig().getProperty("batch.optimize.size").trim()));
145         } catch (Exception e) {
146             LOGGER.error("Please set a value for \"batch.optimize.size\"", e);
147             return BULK_INGEST_OPTIMIZE_SIZE_IN;
148         }
149     }
150 
151     private static int getBulkThreadsMin() {
152         try {
153             return new Integer(ConfigContext.getCurrentContextConfig().getProperty("batch.threads.min").trim());
154         } catch (Exception e) {
155             LOGGER.error("Please set an integer value for \"batch.threads.min\"");
156             return BULK_PROCESSOR_THREADS_MIN_IN;
157         }
158     }
159 
160     private static int getBulkThreadsMax() {
161         try {
162             return new Integer(ConfigContext.getCurrentContextConfig().getProperty("batch.threads.max").trim());
163         } catch (Exception e) {
164             LOGGER.error("Please set an integer value for \"batch.threads.max\"");
165             return BULK_PROCESSOR_THREADS_MAX_IN;
166         }
167     }
168 
169     private static boolean getIsMultiThreaded() {
170         try {
171             return false; // YTI
172             // return new Boolean(PropertyUtil.getPropertyUtil().getProperty("batch.threads.multiThreaded").trim());
173         } catch (Exception e) {
174             LOGGER.error("Please set a value for \"batch.threads.multithreaded\"", e);
175             return BULK_PROCESSOR_MULTI_THREADED_IN;
176         }
177     }
178 
179     private static boolean getIsLinkingEnabled() {
180         try {
181             return new Boolean(ConfigContext.getCurrentContextConfig().getProperty("batch.linking.enabled").trim());
182         } catch (Exception e) {
183             LOGGER.error("Please set a value for \"batch.linking.enabled\"", e);
184             return BULK_INGEST_IS_LINKING_ENABLED_IN;
185         }
186     }
187 
188     private static boolean getIsReIndexingLinkingEnabled() {
189         try {
190             return new Boolean(ConfigContext.getCurrentContextConfig().getProperty("rebuild.indexing.link.enable").trim());
191         } catch (Exception e) {
192             LOGGER.error("Please set a value for \"rebuild.indexing.link.enable\"", e);
193             return REBUILD_INDEXING_LINKING;
194         }
195     }
196 
197     private static long getCommitSize() {
198         try {
199             return (new Long(ConfigContext.getCurrentContextConfig().getProperty("batch.commit.size").trim()));
200         } catch (Exception e) {
201             LOGGER.error("Please set a value for \"batch.commit.size\"", e);
202             return BULK_INGEST_COMMIT_SIZE_IN;
203         }
204     }
205 
206     private static boolean getIsUpdateEnabled() {
207         try {
208             return new Boolean(ConfigContext.getCurrentContextConfig().getProperty("batch.update.enabled").trim());
209         } catch (Exception e) {
210             LOGGER.error("Please set a value for \"batch.update.enabled\"", e);
211             return IS_UPDATE_ENABLED_IN;
212         }
213     }
214 }