/** * Updates the parsed metadata based on the properties of the * {@link ServiceReference}.<p> * This updates the index name, server name, and the directory value based * on the corresponding keys as defined in {@link SolrConstants} * @param metadata the metadata to update * @param coreRef the ServiceReference used to update the metadata */ public static void updateMetadata(IndexMetadata metadata, ServiceReference coreRef){ if(metadata == null || coreRef == null){ return; } // if(SolrCore.class.getName().equals(coreRef.getProperty(Constants.OBJECTCLASS))){ String value = (String)coreRef.getProperty(SolrConstants.PROPERTY_CORE_DIR); if(value != null){ metadata.setDirectory(value); } value = (String) coreRef.getProperty(SolrConstants.PROPERTY_CORE_NAME); if(value != null){ metadata.setIndexName(value); } value = (String) coreRef.getProperty(SolrConstants.PROPERTY_SERVER_NAME); if(value != null){ metadata.setServerName(value); } // } //else parsed service Reference does not refer to a SolrCore } }
/** * Updates the parsed metadata based on the properties of the * {@link ServiceReference}.<p> * This updates the index name, server name, and the directory value based * on the corresponding keys as defined in {@link SolrConstants} * @param metadata the metadata to update * @param coreRef the ServiceReference used to update the metadata */ public static void updateMetadata(IndexMetadata metadata, ServiceReference coreRef){ if(metadata == null || coreRef == null){ return; } // if(SolrCore.class.getName().equals(coreRef.getProperty(Constants.OBJECTCLASS))){ String value = (String)coreRef.getProperty(SolrConstants.PROPERTY_CORE_DIR); if(value != null){ metadata.setDirectory(value); } value = (String) coreRef.getProperty(SolrConstants.PROPERTY_CORE_NAME); if(value != null){ metadata.setIndexName(value); } value = (String) coreRef.getProperty(SolrConstants.PROPERTY_SERVER_NAME); if(value != null){ metadata.setServerName(value); } // } //else parsed service Reference does not refer to a SolrCore } }
metadata.setDirectory(coreDir.getAbsolutePath()); } catch (Exception e) { throw new IllegalStateException(String.format( metadata.setDirectory(coreDir.getAbsolutePath());
metadata.setDirectory(coreDir.getAbsolutePath()); } catch (Exception e) { throw new IllegalStateException(String.format( metadata.setDirectory(coreDir.getAbsolutePath());
IndexMetadata core2Metadata = getIndexMetadata(indexName2); String core2Directory = core2Metadata.getDirectory(); core2Metadata.setDirectory(core1Metadata.getDirectory()); core1Metadata.setDirectory(core2Directory); managedCores.store(core1Metadata); managedCores.store(core2Metadata);
IndexMetadata core2Metadata = getIndexMetadata(indexName2); String core2Directory = core2Metadata.getDirectory(); core2Metadata.setDirectory(core1Metadata.getDirectory()); core1Metadata.setDirectory(core2Directory); managedCores.store(core1Metadata); managedCores.store(core2Metadata);
count++; metadata.setDirectory(coreDir.getName()); //TODO maybe we need to call getAbsolute path
count++; metadata.setDirectory(coreDir.getName()); //TODO maybe we need to call getAbsolute path
metadata.setDirectory(null); //no directory assigned
metadata.setDirectory(null); //no directory assigned
/** * Updates the parsed {@link IndexMetadata} instance based on the * properties of the parsed {@link SolrCore}.<p> * This sets the state, index name and the directory. * @param metadata the {@link IndexMetadata} to update * @param core the core */ public static void updateMetadata(IndexMetadata metadata, SolrCore core){ if(metadata == null || core == null){ return; } metadata.setState(ManagedIndexState.ACTIVE); metadata.setIndexName(core.getName()); metadata.setDirectory(core.getCoreDescriptor().getInstanceDir()); } /**
/** * Updates the parsed {@link IndexMetadata} instance based on the * properties of the parsed {@link SolrCore}.<p> * This sets the state, index name and the directory. * @param metadata the {@link IndexMetadata} to update * @param core the core */ public static void updateMetadata(IndexMetadata metadata, SolrCore core){ if(metadata == null || core == null){ return; } metadata.setState(ManagedIndexState.ACTIVE); metadata.setIndexName(core.getName()); metadata.setDirectory(core.getCoreDescriptor().getInstanceDir()); } /**
@Override public IndexMetadata updateIndex(String indexName, String resourceName, Properties properties) throws IOException { //NOTE: this does not deactivate the current index version, but only updates //the metadata and re-registers the DataFileTracking IndexMetadata oldMetadata = managedCores.getIndexMetadata(indexName); IndexMetadata metadata = new IndexMetadata(); if(properties != null){ metadata.putAll(properties); } metadata.setServerName(serverName); metadata.setIndexName(indexName); metadata.setIndexArchives(Collections.singletonList(resourceName)); if(oldMetadata != null){ //we need to metadata.setState(oldMetadata.getState()); //same as for the old version metadata.setDirectory(oldMetadata.getDirectory()); } else { metadata.setState(ManagedIndexState.UNINITIALISED); } //TODO: we need to deal with the synchronised property! // now add the index to the list of uninitialised managedCores.store(metadata); indexArchiveTracker.updateTracking(oldMetadata,metadata); return metadata; } @Override
@Override public IndexMetadata updateIndex(String indexName, String resourceName, Properties properties) throws IOException { //NOTE: this does not deactivate the current index version, but only updates //the metadata and re-registers the DataFileTracking IndexMetadata oldMetadata = managedCores.getIndexMetadata(indexName); IndexMetadata metadata = new IndexMetadata(); if(properties != null){ metadata.putAll(properties); } metadata.setServerName(serverName); metadata.setIndexName(indexName); metadata.setIndexArchives(Collections.singletonList(resourceName)); if(oldMetadata != null){ //we need to metadata.setState(oldMetadata.getState()); //same as for the old version metadata.setDirectory(oldMetadata.getDirectory()); } else { metadata.setState(ManagedIndexState.UNINITIALISED); } //TODO: we need to deal with the synchronised property! // now add the index to the list of uninitialised managedCores.store(metadata); indexArchiveTracker.updateTracking(oldMetadata,metadata); return metadata; } @Override