/** * All the files are copied to a temp dir first */ private File createTempindexDir(SolrCore core) { String tmpIdxDirName = "index." + new SimpleDateFormat(SnapShooter.DATE_FMT).format(new Date()); File tmpIdxDir = new File(core.getDataDir(), tmpIdxDirName); tmpIdxDir.mkdirs(); return tmpIdxDir; }
Properties loadReplicationProperties() { FileInputStream inFile = null; Properties props = new Properties(); try { File f = new File(core.getDataDir(), SnapPuller.REPLICATION_PROPERTIES); if (f.exists()) { inFile = new FileInputStream(f); props.load(inFile); } } catch (Exception e) { LOG.warn("Exception while reading " + SnapPuller.REPLICATION_PROPERTIES); } finally { IOUtils.closeQuietly(inFile); } return props; }
/** * Tell all {@link SolrCoreAware} instances about the SolrCore */ public void inform(SolrCore core) { this.dataDir = core.getDataDir(); for( SolrCoreAware aware : waitingForCore ) { aware.inform( core ); } waitingForCore.clear(); }
/** * Tell all {@link SolrCoreAware} instances about the SolrCore */ public void inform(SolrCore core) { this.dataDir = core.getDataDir(); // make a copy to avoid potential deadlock of a callback calling newInstance and trying to // add something to waitingForCore. SolrCoreAware[] arr; while (waitingForCore.size() > 0) { synchronized (waitingForCore) { arr = waitingForCore.toArray(new SolrCoreAware[waitingForCore.size()]); waitingForCore.clear(); } for( SolrCoreAware aware : arr) { aware.inform( core ); } } // this is the last method to be called in SolrCore before the latch is released. live = true; }
/** * Activated this indexing configuration by inspecting the {@link SolrCore} * based on the provided configuration * @return */ public void activate() throws IOException { active = true; if(index == null){ //do we have an SolrCore throw new IllegalArgumentException("No SolrCore set for this configuration"); } //if no fstDirectory is configured if(fstDirectory == null){ //use the default fstDirectory = new File(index.getDataDir(),"fst"); } //init the fstDirectory (may throw IOException) if(fstDirectory.isFile()){ throw new IOException("Default FST directory exists and " + "is a File. Use #setFstDirectory() to set different one"); } else if(!fstDirectory.exists()){ FileUtils.forceMkdir(fstDirectory); } //acquire the initial index configuration update(); }
@Override public String lookup(String key) { if("solr-data-dir".equals(key)){ return core.getDataDir(); } else if("solr-index-dir".equals(key)){ return core.getIndexDir(); } else if("solr-server-name".equals(key)){ return indexRef.getServer(); } else if("solr-core-name".equals(key)){ return core.getName(); } else { return bc.getProperty(key); } }
public SnapShooter(SolrCore core, String location) throws IOException { solrCore = core; if (location == null) snapDir = core.getDataDir(); else { File base = new File(core.getCoreDescriptor().getInstanceDir()); snapDir = org.apache.solr.common.util.FileUtils.resolvePath(base, location).getAbsolutePath(); File dir = new File(snapDir); if (!dir.exists()) dir.mkdirs(); } lockFactory = new SimpleFSLockFactory(snapDir); }
File idxprops = new File(solrCore.getDataDir() + "index.properties"); Properties p = new Properties(); if (idxprops.exists()) {
public FileFloatSource(SchemaField field, SchemaField keyField, float defVal, QParser parser) { this.field = field; this.keyField = keyField; this.defVal = defVal; this.dataDir = parser.getReq().getCore().getDataDir(); }
props.setProperty(REPLICATION_FAILED_AT_LIST, sb.toString()); File f = new File(solrCore.getDataDir(), REPLICATION_PROPERTIES); outFile = new FileOutputStream(f); props.store(outFile, "Replication details");
public void inform(SolrCore core) { termSourceField = args.get(SOURCE_FIELD, args.get("termSourceField")); try { String dir = args.get(INDEX_DIR, args.get("spellcheckerIndexDir")); if (null != dir) { File f = new File(dir); if ( ! f.isAbsolute() ) { f = new File(core.getDataDir(), dir); } dirDescription = f.getAbsolutePath(); log.info("using spell directory: " + dirDescription); spellcheckerIndexDir = FSDirectory.getDirectory(f); } else { log.info("using RAM based spell directory"); } spellChecker = new SpellChecker(spellcheckerIndexDir); } catch (IOException e) { throw new RuntimeException("Cannot open SpellChecker index", e); } }
Map<String, ElevationObj> getElevationMap( IndexReader reader, SolrCore core ) throws Exception { synchronized( elevationCache ) { Map<String, ElevationObj> map = elevationCache.get( null ); if (map != null) return map; map = elevationCache.get( reader ); if( map == null ) { String f = initArgs.get( CONFIG_FILE ); if( f == null ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "QueryElevationComponent must specify argument: "+CONFIG_FILE ); } log.info( "Loading QueryElevation from data dir: "+f ); InputStream is = VersionedFile.getLatestFile( core.getDataDir(), f ); Config cfg = new Config( core.getResourceLoader(), f, is, null ); map = loadElevationMap( cfg ); elevationCache.put( reader, map ); } return map; } }
props.put(PROPERTY_CORE_NAME, name); props.put(PROPERTY_CORE_DIR, core.getCoreDescriptor().getInstanceDir()); props.put(PROPERTY_CORE_DATA_DIR, core.getDataDir()); props.put(PROPERTY_CORE_INDEX_DIR, core.getIndexDir()); props.put(PROPERTY_CORE_SCHEMA, core.getSchemaResource());
props.put(PROPERTY_CORE_NAME, name); props.put(PROPERTY_CORE_DIR, core.getCoreDescriptor().getInstanceDir()); props.put(PROPERTY_CORE_DATA_DIR, core.getDataDir()); props.put(PROPERTY_CORE_INDEX_DIR, core.getIndexDir()); props.put(PROPERTY_CORE_SCHEMA, core.getSchemaResource());
storeDir = new File(store); if (!storeDir.isAbsolute()) { storeDir = new File(core.getDataDir() + File.separator + storeDir);
storeDir = new File(store); if (!storeDir.isAbsolute()) { storeDir = new File(core.getDataDir() + File.separator + storeDir);
/** * Get system info */ private static SimpleOrderedMap<Object> getCoreInfo( SolrCore core ) throws Exception { SimpleOrderedMap<Object> info = new SimpleOrderedMap<Object>(); IndexSchema schema = core.getSchema(); info.add( "schema", schema != null ? schema.getSchemaName():"no schema!" ); // Host InetAddress addr = InetAddress.getLocalHost(); info.add( "host", addr.getCanonicalHostName() ); // Now info.add( "now", new Date() ); // Start Time info.add( "start", new Date(core.getStartTime()) ); // Solr Home SimpleOrderedMap<Object> dirs = new SimpleOrderedMap<Object>(); dirs.add( "instance", new File( core.getResourceLoader().getInstanceDir() ).getAbsolutePath() ); dirs.add( "data", new File( core.getDataDir() ).getAbsolutePath() ); dirs.add( "index", new File( core.getIndexDir() ).getAbsolutePath() ); info.add( "directory", dirs ); return info; }
File fD = new File( core.getDataDir(), f ); if( fC.exists() == fD.exists() ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
indexDir = core.getDataDir() + File.separator + indexDir;
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname) throws IOException { NamedList<Object> info = new SimpleOrderedMap<Object>(); SolrCore core = cores.getCore(cname); if (core != null) { try { info.add("name", core.getName()); info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir())); info.add("dataDir", normalizePath(core.getDataDir())); info.add("startTime", new Date(core.getStartTime())); info.add("uptime", System.currentTimeMillis() - core.getStartTime()); RefCounted<SolrIndexSearcher> searcher = core.getSearcher(); try { info.add("index", LukeRequestHandler.getIndexInfo(searcher.get().getReader(), false)); } finally { searcher.decref(); } } finally { core.close(); } } return info; }