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.ole.docstore.util.PropertyUtil;
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 PropertyUtil.getPropertyUtil().getProperty("batch.user").trim();
109         }
110         catch (Exception e) {
111             LOGGER.error("Please set a value for \"batch.user\"", e);
112             return BULK_DEFAULT_USER_IN;
113         }
114     }
115 
116     public static String getBulkUploadDir() {
117         try {
118             return PropertyUtil.getPropertyUtil().getProperty("batch.upload.dir").trim();
119         }
120         catch (Exception e) {
121             LOGGER.error("Please set a value for \"batch.upload.dir\"", e);
122             return BULK_INGEST_UPLOAD_DIR_IN;
123         }
124     }
125 
126     private static int getSplitSize() {
127         try {
128             return new Integer(PropertyUtil.getPropertyUtil().getProperty("batch.split.size").trim()).intValue();
129         }
130         catch (Exception e) {
131             LOGGER.error("Please set a value for \"batch.split.size\"", e);
132             return BULK_PROCESSOR_SPLIT_SIZE_IN;
133         }
134     }
135 
136     private static long getPollInterval() {
137         try {
138             return (new Long(PropertyUtil.getPropertyUtil().getProperty("batch.poll.intervel").trim()) * 60L * 1000L);
139         }
140         catch (Exception e) {
141             LOGGER.error("Please set a value for \"batch.poll.intervel\"", e);
142             return BULK_INGEST_POLL_INTERVAL_IN;
143         }
144     }
145 
146     private static long getOptimizeSize() {
147         try {
148             return (new Long(PropertyUtil.getPropertyUtil().getProperty("batch.optimize.size").trim()));
149         }
150         catch (Exception e) {
151             LOGGER.error("Please set a value for \"batch.optimize.size\"", e);
152             return BULK_INGEST_OPTIMIZE_SIZE_IN;
153         }
154     }
155 
156     private static int getBulkThreadsMin() {
157         try {
158             return new Integer(PropertyUtil.getPropertyUtil().getProperty("batch.threads.min").trim());
159         }
160         catch (Exception e) {
161             LOGGER.error("Please set an integer value for \"batch.threads.min\"");
162             return BULK_PROCESSOR_THREADS_MIN_IN;
163         }
164     }
165 
166     private static int getBulkThreadsMax() {
167         try {
168             return new Integer(PropertyUtil.getPropertyUtil().getProperty("batch.threads.max").trim());
169         }
170         catch (Exception e) {
171             LOGGER.error("Please set an integer value for \"batch.threads.max\"");
172             return BULK_PROCESSOR_THREADS_MAX_IN;
173         }
174     }
175 
176     private static boolean getIsMultiThreaded() {
177         try {
178             return false; // YTI
179             // return new Boolean(PropertyUtil.getPropertyUtil().getProperty("batch.threads.multiThreaded").trim());
180         }
181         catch (Exception e) {
182             LOGGER.error("Please set a value for \"batch.threads.multithreaded\"", e);
183             return BULK_PROCESSOR_MULTI_THREADED_IN;
184         }
185     }
186 
187     private static boolean getIsLinkingEnabled() {
188         try {
189             return new Boolean(PropertyUtil.getPropertyUtil().getProperty("batch.linking.enabled").trim());
190         }
191         catch (Exception e) {
192             LOGGER.error("Please set a value for \"batch.linking.enabled\"", e);
193             return BULK_INGEST_IS_LINKING_ENABLED_IN;
194         }
195     }
196 
197     private static boolean getIsReIndexingLinkingEnabled() {
198         try {
199             return new Boolean(PropertyUtil.getPropertyUtil().getProperty("rebuild.indexing.link.enable").trim());
200         }
201         catch (Exception e) {
202             LOGGER.error("Please set a value for \"rebuild.indexing.link.enable\"", e);
203             return REBUILD_INDEXING_LINKING;
204         }
205     }
206 
207     private static long getCommitSize() {
208         try {
209             return (new Long(PropertyUtil.getPropertyUtil().getProperty("batch.commit.size").trim()));
210         }
211         catch (Exception e) {
212             LOGGER.error("Please set a value for \"batch.commit.size\"", e);
213             return BULK_INGEST_COMMIT_SIZE_IN;
214         }
215     }
216 
217     private static boolean getIsUpdateEnabled() {
218         try {
219             return new Boolean(PropertyUtil.getPropertyUtil().getProperty("batch.update.enabled").trim());
220         }
221         catch (Exception e) {
222             LOGGER.error("Please set a value for \"batch.update.enabled\"", e);
223             return IS_UPDATE_ENABLED_IN;
224         }
225     }
226 }