/** * 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.putAll(properties); metadata.setIndexName(name); metadata.setServerName(DEFAULT_SERVER_NAME); metadata.setSynchronized(false);
@Override public IndexMetadata updateIndex(String indexName, ArchiveInputStream ais, String archiveCoreName) throws IOException, SAXException { if(indexName == null || indexName.isEmpty()){ throw new IllegalArgumentException("The parsed name for the index MUST NOT" + "be NULL nor empty!"); } if(ais == null){ throw new IOException("The parsed ArchiveInputStream MUST NOT be NULL!"); } IndexMetadata metadata = new IndexMetadata(); metadata.setServerName(serverName); metadata.setIndexName(indexName); metadata.setSynchronized(false); if (archiveCoreName != null) { metadata.setArchive(archiveCoreName); } try { updateCore(metadata, ais); } finally { managedCores.store(metadata); } return metadata; }
@Override public IndexMetadata updateIndex(String name, ArchiveInputStream ais, String archiveCoreName) throws IOException { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("The parsed index name MUST NOT be NULL nor empty!"); } IndexMetadata metadata = new IndexMetadata(); metadata.setIndexName(name); metadata.setServerName(DEFAULT_SERVER_NAME); metadata.setSynchronized(false); metadata.setState(ManagedIndexState.ACTIVE); if (archiveCoreName != null) { metadata.setArchive(archiveCoreName); } return updateCore(metadata, ais); }
@Override public IndexMetadata updateIndex(String name, ArchiveInputStream ais, String archiveCoreName) throws IOException { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("The parsed index name MUST NOT be NULL nor empty!"); } IndexMetadata metadata = new IndexMetadata(); metadata.setIndexName(name); metadata.setServerName(DEFAULT_SERVER_NAME); metadata.setSynchronized(false); metadata.setState(ManagedIndexState.ACTIVE); if (archiveCoreName != null) { metadata.setArchive(archiveCoreName); } return updateCore(metadata, ais); }
metadata.putAll(properties); metadata.setIndexName(name); metadata.setServerName(DEFAULT_SERVER_NAME); metadata.setSynchronized(false);
@Override public IndexMetadata updateIndex(String indexName, ArchiveInputStream ais, String archiveCoreName) throws IOException, SAXException { if(indexName == null || indexName.isEmpty()){ throw new IllegalArgumentException("The parsed name for the index MUST NOT" + "be NULL nor empty!"); } if(ais == null){ throw new IOException("The parsed ArchiveInputStream MUST NOT be NULL!"); } IndexMetadata metadata = new IndexMetadata(); metadata.setServerName(serverName); metadata.setIndexName(indexName); metadata.setSynchronized(false); if (archiveCoreName != null) { metadata.setArchive(archiveCoreName); } try { updateCore(metadata, ais); } finally { managedCores.store(metadata); } return metadata; }
@Override public IndexMetadata createSolrIndex(String indexName, String resourceName, Properties properties) throws IOException { if(indexName == null || indexName.isEmpty()){ throw new IllegalArgumentException("The parsed index name MUST NOT be NULL nor empty!"); } if(!ConfigUtils.isValidSolrIndexFileName(resourceName)){ log.debug("add SolrIndexFileExtension to parsed indexArchive {}",resourceName); resourceName = ConfigUtils.appandSolrIndexFileExtension(resourceName, null); } if(isManagedIndex(indexName)){ throw new IllegalArgumentException("An index with the parsed name '"+ indexName+"' already exists on this managed Solr server '"+serverName+"'!"); } IndexMetadata metadata = new IndexMetadata(); if(properties != null){ metadata.putAll(properties); } metadata.setServerName(serverName); metadata.setIndexName(indexName); metadata.setIndexArchives(Collections.singletonList(resourceName)); 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); //now start tracking this archive file indexArchiveTracker.addTracking(metadata); dataFileTracker.add(indexArchiveTracker, resourceName, IndexMetadata.toStringMap(metadata)); return metadata; }
/** * 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()); } /**
public void addUninitialisedIndex(String indexName, String indexArchiveName, Boolean sync) throws IOException { IndexMetadata config = new IndexMetadata(); config = new IndexMetadata(); config.setIndexName(indexName); config.setServerName(serverName); config.setState(ManagedIndexState.UNINITIALISED); if(sync != null){ config.setSynchronized(sync); } //no need to clone, because we have created the instance updateIndexProperties(null, config, false); } public void store(IndexMetadata properties){
public void addUninitialisedIndex(String indexName, String indexArchiveName, Boolean sync) throws IOException { IndexMetadata config = new IndexMetadata(); config = new IndexMetadata(); config.setIndexName(indexName); config.setServerName(serverName); config.setState(ManagedIndexState.UNINITIALISED); if(sync != null){ config.setSynchronized(sync); } //no need to clone, because we have created the instance updateIndexProperties(null, config, false); } public void store(IndexMetadata properties){
@Override public IndexMetadata createSolrIndex(String indexName, String resourceName, Properties properties) throws IOException { if(indexName == null || indexName.isEmpty()){ throw new IllegalArgumentException("The parsed index name MUST NOT be NULL nor empty!"); } if(!ConfigUtils.isValidSolrIndexFileName(resourceName)){ log.debug("add SolrIndexFileExtension to parsed indexArchive {}",resourceName); resourceName = ConfigUtils.appandSolrIndexFileExtension(resourceName, null); } if(isManagedIndex(indexName)){ throw new IllegalArgumentException("An index with the parsed name '"+ indexName+"' already exists on this managed Solr server '"+serverName+"'!"); } IndexMetadata metadata = new IndexMetadata(); if(properties != null){ metadata.putAll(properties); } metadata.setServerName(serverName); metadata.setIndexName(indexName); metadata.setIndexArchives(Collections.singletonList(resourceName)); 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); //now start tracking this archive file indexArchiveTracker.addTracking(metadata); dataFileTracker.add(indexArchiveTracker, resourceName, IndexMetadata.toStringMap(metadata)); return metadata; }
@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