Revision 10381
Added by Jing Tao over 7 years ago
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java | ||
---|---|---|
139 | 139 |
/* |
140 | 140 |
* Submit a index task to the message broker. |
141 | 141 |
*/ |
142 |
private void submitAddIndexTask(SystemMetadata sysmeta, String objectURI) throws ServiceFailure, InvalidSystemMetadata, InstantiationException, IllegalAccessException, ClassNotFoundException { |
|
143 |
if(indexTaskClient == null) { |
|
144 |
indexTaskClient = IndexTaskMessagingClientManager.getInstance().getMessagingClient(); |
|
142 |
private void submitAddIndexTask(SystemMetadata sysmeta, String methodName, boolean isData) { |
|
143 |
try { |
|
144 |
if(indexTaskClient == null) { |
|
145 |
indexTaskClient = IndexTaskMessagingClientManager.getInstance().getMessagingClient(); |
|
146 |
} |
|
147 |
String objectURI = null; |
|
148 |
if(!isData) { |
|
149 |
String localId = IdentifierManager.getInstance().getLocalId(sysmeta.getIdentifier().getValue()); |
|
150 |
objectURI = IdentifierManager.getInstance().getObjectFilePath(localId, isScienceMetadata(sysmeta)); |
|
151 |
} |
|
152 |
IndexTaskGenerator generator = new IndexTaskGenerator(); |
|
153 |
//The objectURI will be null for data file |
|
154 |
IndexTask task = generator.generateAddTask(sysmeta, objectURI); |
|
155 |
indexTaskClient.submit(task); |
|
156 |
logMetacat.info("CNodeService."+methodName+" - Metacat successfully submitted the index task for the object "+sysmeta.getIdentifier().getValue()+" to the message broker. But it is NOT guarranteed that the broker can get it."); |
|
157 |
} catch (Exception e) { |
|
158 |
logMetacat.warn("CNodeService."+methodName+" - the index task for the object "+sysmeta.getIdentifier().getValue()+" failed to be submitted to the message broker since "+e.getMessage(), e); |
|
145 | 159 |
} |
146 |
IndexTaskGenerator generator = new IndexTaskGenerator(); |
|
147 |
IndexTask task = generator.generateAddTask(sysmeta, objectURI); |
|
148 |
indexTaskClient.submit(task); |
|
149 |
|
|
150 | 160 |
} |
151 | 161 |
|
152 | 162 |
/* |
153 | 163 |
* Submit an update index task to the message broker. |
154 | 164 |
*/ |
155 |
private void submitUpdateIndexTask(SystemMetadata sysmeta, String objectURI) throws ServiceFailure, InvalidSystemMetadata, InstantiationException, IllegalAccessException, ClassNotFoundException { |
|
156 |
if(indexTaskClient == null) { |
|
157 |
indexTaskClient = IndexTaskMessagingClientManager.getInstance().getMessagingClient(); |
|
165 |
private void submitUpdateIndexTask(SystemMetadata sysmeta, String methodName) { |
|
166 |
try { |
|
167 |
if(indexTaskClient == null) { |
|
168 |
indexTaskClient = IndexTaskMessagingClientManager.getInstance().getMessagingClient(); |
|
169 |
} |
|
170 |
String localId = IdentifierManager.getInstance().getLocalId(sysmeta.getIdentifier().getValue()); |
|
171 |
String objectURI = IdentifierManager.getInstance().getObjectFilePath(localId, isScienceMetadata(sysmeta)); |
|
172 |
IndexTaskGenerator generator = new IndexTaskGenerator(); |
|
173 |
IndexTask task = generator.generateUpdateTask(sysmeta, objectURI); |
|
174 |
indexTaskClient.submit(task); |
|
175 |
logMetacat.info("CNodeService."+methodName+" - Metacat successfully submitted the index task for the object "+sysmeta.getIdentifier().getValue()+" to the message broker. But it is NOT guarranteed that the broker can get it."); |
|
176 |
} catch (Exception e) { |
|
177 |
logMetacat.warn("CNodeService."+methodName+" - the index task for the object "+sysmeta.getIdentifier().getValue()+" failed to be submitted to the message broker since "+e.getMessage(), e); |
|
158 | 178 |
} |
159 |
IndexTaskGenerator generator = new IndexTaskGenerator(); |
|
160 |
IndexTask task = generator.generateUpdateTask(sysmeta, objectURI); |
|
161 |
indexTaskClient.submit(task); |
|
162 | 179 |
} |
163 | 180 |
|
164 | 181 |
/* |
165 | 182 |
* Submit a delete index task to the message broker. |
166 | 183 |
*/ |
167 |
private void submitDeleteIndexTask(SystemMetadata sysmeta) throws ServiceFailure, InvalidSystemMetadata, InstantiationException, IllegalAccessException, ClassNotFoundException { |
|
168 |
if(indexTaskClient == null) { |
|
169 |
indexTaskClient = IndexTaskMessagingClientManager.getInstance().getMessagingClient(); |
|
184 |
private void submitDeleteIndexTask(SystemMetadata sysmeta, String methodName) { |
|
185 |
try { |
|
186 |
if(indexTaskClient == null) { |
|
187 |
indexTaskClient = IndexTaskMessagingClientManager.getInstance().getMessagingClient(); |
|
188 |
} |
|
189 |
IndexTaskGenerator generator = new IndexTaskGenerator(); |
|
190 |
IndexTask task = generator.generateDeleteTask(sysmeta); |
|
191 |
indexTaskClient.submit(task); |
|
192 |
logMetacat.info("CNodeService."+methodName+" - Metacat successfully submitted the index task for the object "+sysmeta.getIdentifier().getValue()+" to the message broker. But it is NOT guarranteed that the broker can get it."); |
|
193 |
} catch (Exception e) { |
|
194 |
logMetacat.warn("CNodeService."+methodName+" - the index task for the object "+sysmeta.getIdentifier().getValue()+" failed to be submitted to the message broker since "+e.getMessage(), e); |
|
170 | 195 |
} |
171 |
IndexTaskGenerator generator = new IndexTaskGenerator(); |
|
172 |
IndexTask task = generator.generateDeleteTask(sysmeta); |
|
173 |
indexTaskClient.submit(task); |
|
174 | 196 |
} |
175 | 197 |
|
176 | 198 |
/** |
... | ... | |
821 | 843 |
} catch (RuntimeException e) { |
822 | 844 |
throw new ServiceFailure("4882", e.getMessage()); |
823 | 845 |
} |
846 |
|
|
824 | 847 |
|
825 | 848 |
} catch (RuntimeException e) { |
826 | 849 |
throw new ServiceFailure("4882", e.getMessage()); |
... | ... | |
1917 | 1940 |
} |
1918 | 1941 |
pid = super.create(session, pid, object, sysmeta); |
1919 | 1942 |
// submit the index task to the message broker. |
1920 |
try { |
|
1921 |
String localId = IdentifierManager.getInstance().getLocalId(pid.getValue()); |
|
1922 |
String objectURI = IdentifierManager.getInstance().getObjectFilePath(localId, isScienceMetadata(sysmeta)); |
|
1923 |
submitAddIndexTask(sysmeta, objectURI); |
|
1924 |
logMetacat.info("CNodeService.create - Metacat successfully submitted the index task for the object "+sysmeta.getIdentifier().getValue()+" to the message broker. But it is NOT guarranteed that the broker can get it."); |
|
1925 |
} catch (Exception e) { |
|
1926 |
logMetacat.warn("CNodeService.create - the index task for the object "+sysmeta.getIdentifier().getValue()+" failed to be submitted to the message broker since "+e.getMessage(), e); |
|
1927 |
} |
|
1928 |
|
|
1943 |
String methodName="create"; |
|
1944 |
boolean isData = false; |
|
1945 |
submitAddIndexTask(sysmeta, methodName, isData); |
|
1929 | 1946 |
} else { |
1930 | 1947 |
String msg = "The subject listed as " + session.getSubject().getValue() + |
1931 | 1948 |
" isn't allowed to call create() on a Coordinating Node for pid "+pid.getValue(); |
Also available in: Unified diff
Refactory the submit index methods.