/** * Getter for the name of the index within the current * {@link IndexMetadata#getArchive() archive} set to load the index data * from. If no archive is set (e.g. if the {@link ArchiveInputStream} was * directly parsed, than the {@link IndexMetadata#getIndexName() index name} * directly is used as default. * @param metadata the {@link IndexMetadata} * @return the name of the index within the indexArchive used to load the * data from. In other words the relative path to the index data within the * index archive. */ public static String getArchiveCoreName(final IndexMetadata metadata) { String name = metadata.getIndexName(); String archiveCoreName = metadata.getArchive(); if(archiveCoreName == null){ archiveCoreName = name; } else { //the name of the core in the archive MUST BE the same as //the name of the archive excluding .solrindex.{archive-format} int split = archiveCoreName.indexOf('.'); if(split>0){ archiveCoreName = archiveCoreName.substring(0,split); } } return archiveCoreName; } // /**
/** * Getter for the name of the index within the current * {@link IndexMetadata#getArchive() archive} set to load the index data * from. If no archive is set (e.g. if the {@link ArchiveInputStream} was * directly parsed, than the {@link IndexMetadata#getIndexName() index name} * directly is used as default. * @param metadata the {@link IndexMetadata} * @return the name of the index within the indexArchive used to load the * data from. In other words the relative path to the index data within the * index archive. */ public static String getArchiveCoreName(final IndexMetadata metadata) { String name = metadata.getIndexName(); String archiveCoreName = metadata.getArchive(); if(archiveCoreName == null){ archiveCoreName = name; } else { //the name of the core in the archive MUST BE the same as //the name of the archive excluding .solrindex.{archive-format} int split = archiveCoreName.indexOf('.'); if(split>0){ archiveCoreName = archiveCoreName.substring(0,split); } } return archiveCoreName; } // /**
/** * Getter for the {@link IndexReference} based on the {@link #getServerName()} and * {@link #getIndexName()} values * @return the {@link IndexReference} to the index described by this metadata */ public IndexReference getIndexReference(){ return new IndexReference(getServerName(), getIndexName()); } /**
/** * Getter for the {@link IndexReference} based on the {@link #getServerName()} and * {@link #getIndexName()} values * @return the {@link IndexReference} to the index described by this metadata */ public IndexReference getIndexReference(){ return new IndexReference(getServerName(), getIndexName()); } /**
throw new IllegalArgumentException("The parsed IndexMetadata MUST NOT be NULL"); String name = metadata.getIndexName(); if(name == null || name.isEmpty()){ throw new IllegalArgumentException("The parsed IndexMetadata MUST contain a valid name (NOT NULL and NOT empty)!"); new Object[]{metadata.getIndexName(), metadata.getServerName(), desiredState.name(), metadata.getArchive()}); switch (desiredState) {
throw new IllegalArgumentException("The parsed IndexMetadata MUST NOT be NULL"); String name = metadata.getIndexName(); if(name == null || name.isEmpty()){ throw new IllegalArgumentException("The parsed IndexMetadata MUST contain a valid name (NOT NULL and NOT empty)!"); new Object[]{metadata.getIndexName(), metadata.getServerName(), desiredState.name(), metadata.getArchive()}); switch (desiredState) {
SolrCoreProperties coreConfig = new SolrCoreProperties(metadata.getIndexName()); coreConfig.setCoreDir(new File(managedSolrDir,metadata.getDirectory())); Object token = new Object(); "Unable to activate the SolrCore configuration for index " + "'%s' of managed SolrServer '%s'", metadata.getIndexName(), serverName), e); } finally { synchronized (serverInUser) {
SolrCoreProperties coreConfig = new SolrCoreProperties(metadata.getIndexName()); coreConfig.setCoreDir(new File(managedSolrDir,metadata.getDirectory())); Object token = new Object(); "Unable to activate the SolrCore configuration for index " + "'%s' of managed SolrServer '%s'", metadata.getIndexName(), serverName), e); } finally { synchronized (serverInUser) {
props.load(is); if(!indexName.equals(props.getIndexName())){ throw new IOException("The IndexName '"+props.getIndexName()+ "within the IndexConfig file does not correspond to the file name '"+ file+"'!");
props.load(is); if(!indexName.equals(props.getIndexName())){ throw new IOException("The IndexName '"+props.getIndexName()+ "within the IndexConfig file does not correspond to the file name '"+ file+"'!");
private IndexMetadata updateCore(IndexMetadata metadata, ArchiveInputStream ais){ String indexName = metadata.getIndexName(); File coreDir = new File(managedSolrDir, indexName); if(!initCores.contains(indexName)){
private IndexMetadata updateCore(IndexMetadata metadata, ArchiveInputStream ais){ String indexName = metadata.getIndexName(); File coreDir = new File(managedSolrDir, indexName); if(!initCores.contains(indexName)){
/** * validates the values of the IndexProperties * @throws IOException */ private void validate(boolean store) throws IOException { if(isSynchronized() && getIndexArchives().isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Synchronized=true and no Index-Archives are defined!"); } ManagedIndexState state = getState(); if(state == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexMetadata without the required key '"+STATE+ "' set to one of the values '"+ Arrays.toString(ManagedIndexState.values())+"'!"); } if(isActive()){ if(getDirectory() == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Active=true and no Directory is defined!"); } } String name = getIndexName(); if(name == null || name.isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where the required key '"+ INDEX_NAME+"' is not defined or empty!"); } }
/** * validates the values of the IndexProperties * @throws IOException */ private void validate(boolean store) throws IOException { if(isSynchronized() && getIndexArchives().isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Synchronized=true and no Index-Archives are defined!"); } ManagedIndexState state = getState(); if(state == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexMetadata without the required key '"+STATE+ "' set to one of the values '"+ Arrays.toString(ManagedIndexState.values())+"'!"); } if(isActive()){ if(getDirectory() == null){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where Active=true and no Directory is defined!"); } } String name = getIndexName(); if(name == null || name.isEmpty()){ throw new IOException("Unable to "+(store?"store":"read")+ " IndexPropertis where the required key '"+ INDEX_NAME+"' is not defined or empty!"); } }
File coreDir = null; if(metadata.isActive()){ coreDir = deactivateCore(metadata.getIndexName(), server); "removed index '%s' of the managed SolrServer '{}'. " + "Please try to delete this directory manually!", coreDir.getAbsolutePath(),metadata.getIndexName(), serverName),e);
File coreDir = null; if(metadata.isActive()){ coreDir = deactivateCore(metadata.getIndexName(), server); "removed index '%s' of the managed SolrServer '{}'. " + "Please try to delete this directory manually!", coreDir.getAbsolutePath(),metadata.getIndexName(), serverName),e);
return null; if(name != null && properties != null && !name.equals(properties.getIndexName())){ throw new IllegalArgumentException("The value of the Index-Name property '"+ properties.getIndexName()+"' is not the same as the parsed name '"+ name+"'!"); name = properties.getIndexName();
log.error("IOException while activating Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } catch (SAXException e) { log.error("SAXException while activating Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } catch (RuntimeException e) { log.error("Exception while activating Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } finally { log.error("Exception while uninitialising Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } finally {
log.error("IOException while activating Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } catch (SAXException e) { log.error("SAXException while activating Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } catch (RuntimeException e) { log.error("Exception while activating Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } finally { log.error("Exception while uninitialising Index '"+ info.metadata.getServerName()+':'+ info.metadata.getIndexName()+"'!",e); info.metadata.setError(e); } finally {
new Object[]{solrIndexRef.getIndex(),managedServer.getServerName(),metadata.getState()}); try { managedServer.activateIndex(metadata.getIndexName()); } catch (IOException e) { throw new IllegalStateException("Unable to activate Managed SolrIndex "