use of org.apache.stanbol.commons.solr.managed.IndexMetadata in project stanbol by apache.
the class ManagedSolrServerImpl method createSolrIndex.
@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;
}
use of org.apache.stanbol.commons.solr.managed.IndexMetadata in project stanbol by apache.
the class StandaloneManagedSolrServer method updateIndex.
@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);
}
use of org.apache.stanbol.commons.solr.managed.IndexMetadata in project stanbol by apache.
the class StandaloneManagedSolrServer method deactivateIndex.
@Override
public IndexMetadata deactivateIndex(String indexName) {
IndexMetadata metadata;
SolrCore core = server.remove(indexName);
if (core != null) {
metadata = getMetadata(core, serverName);
core.close();
metadata.setState(ManagedIndexState.INACTIVE);
} else {
metadata = null;
}
return metadata;
}
use of org.apache.stanbol.commons.solr.managed.IndexMetadata in project stanbol by apache.
the class StandaloneManagedSolrServer method getIndexMetadata.
@Override
public IndexMetadata getIndexMetadata(String indexName) {
IndexMetadata metadata;
SolrCore core = server.getCore(indexName);
if (core != null) {
metadata = getMetadata(core, serverName);
core.close();
} else {
metadata = null;
}
return metadata;
}
use of org.apache.stanbol.commons.solr.managed.IndexMetadata in project stanbol by apache.
the class ManagementUtils method getMetadata.
// /**
// * Parses the name of the Core from an IndexReference (file url, file path,
// * index name or server:indexname)
// * @param indexRef the parsed indexRef
// * @return
// */
// public static String getCoreNameForIndexRef(String indexRef,String serverName) {
//
// String[] parsedRef = ConfigUtils.parseSolrServerReference(indexRef);
// String coreName;
// if(parsedRef[0] != null && !parsedRef[0].equals(serverName)){
// coreName = null; //other server
// } else {
// coreName = parsedRef[1];
// if(coreName == null || coreName.isEmpty()){
// log.warn("The parsed index reference '"+indexRef+"' does not define a valid core name!");
// }
// }
// return coreName;
// }
/**
* Creates and initialises a {@link IndexMetadata} instance based on the
* parsed {@link SolrCore}
* @param core the {@link SolrCore}
* @param serverName the name of the server
* @return the initialised {@link IndexMetadata}
*/
public static IndexMetadata getMetadata(SolrCore core, String serverName) {
if (core == null) {
return null;
}
IndexMetadata metadata = new IndexMetadata();
if (serverName != null) {
metadata.setServerName(serverName);
}
metadata.setSynchronized(false);
updateMetadata(metadata, core);
return metadata;
}
Aggregations