/** * Creates a new instance of ApacheDsService. It initializes the directory * service. * * @throws Exception * If something went wrong */ @Activate public void activate(BundleContext context) { File workDir; try { workDir = new File(getDsHome(context)); log.info("ApacheDsService startup: schema.resource.location ="+context.getBundle().getSymbolicName()+"("+context.getBundle().getBundleId()+") - working directory: "+workDir.getAbsolutePath()); cacheService = new CacheService(); service = new ApacheDsService(); service.start(new InstanceLayout(workDir), cacheService); serviceReg = context.registerService(ApacheDsService.class.getName(), service, null); } catch (IOException e) { log.error("Error activating Apache Directory Service", e); } catch (Exception e) { log.error("Error activating Apache Directory Service", e); } }
/** * Initialize the schema partition * * @param instanceLayout the instance layout * @throws Exception in case of any problems while initializing the SchemaPartition */ private void initSchemaLdifPartition( InstanceLayout instanceLayout ) throws Exception { File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" ); // Init the LdifPartition schemaLdifPartition = new LdifPartition( schemaManager ); schemaLdifPartition.setPartitionPath( schemaPartitionDirectory.toURI() ); }
/** * @see String#toString() */ public String toString() { return "Instance Layout: \n" + " Instance dir : " + getInstanceDirectory() + "\n" + " Instance conf dir : " + getConfDirectory() + "\n" + " Instance log dir : " + getLogDirectory() + "\n" + " Instance run dir : " + getRunDirectory() + "\n" + " Instance partitions dir : " + getPartitionsDirectory() + "\n" + " Instance replication data dir : " + getReplDirectory() + "\n" + " Instance cache dir : " + getCacheDirectory() + "\n"; } }
/** * Initializes the InstanceLayout. */ private void init() { // The required directories File[] requiredDirectories = new File[] { getInstanceDirectory(), getConfDirectory(), getLogDirectory(), getPartitionsDirectory(), getRunDirectory(), getCacheDirectory() }; setRequiredDirectories( requiredDirectories ); // The required files File[] requiredFiles = new File[] { getWrapperConfigurationFile(), getLogConfigurationFile() /*, getApacheDsConfigurationLdifFile() */// TODO re-activate this when possible. }; setRequiredFiles( requiredFiles ); }
/** * Build the working directory */ private void buildInstanceDirectory( String name ) throws IOException { String instanceDirectory = System.getProperty( "workingDirectory" ); if ( instanceDirectory == null ) { instanceDirectory = System.getProperty( "java.io.tmpdir" ) + "/server-work-" + name; } InstanceLayout instanceLayout = new InstanceLayout( instanceDirectory ); if ( instanceLayout.getInstanceDirectory().exists() ) { try { FileUtils.deleteDirectory( instanceLayout.getInstanceDirectory() ); } catch ( IOException e ) { LOG.warn( "couldn't delete the instance directory before initializing the DirectoryService", e ); } } directoryService.setInstanceLayout( instanceLayout ); }
private void initDirectoryService() throws Exception { ds = new DefaultDirectoryService(); ds.setInstanceLayout(new InstanceLayout(workDir)); instanceLayout.getPartitionsDirectory(), "schema"); SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory()); extractor.extractOrCopy(); systemPartition.setId("system"); systemPartition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI()); systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN)); partition.setId(orgName); partition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI()); partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain)); ds.addPartition(partition);
InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + directoryService.getInstanceId()); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager());
if ( !instanceLayout.getInstanceDirectory().exists() ) if ( !instanceLayout.getInstanceDirectory().mkdirs() ) instanceLayout.getInstanceDirectory() ) ); if ( !instanceLayout.getLogDirectory().exists() ) if ( !instanceLayout.getLogDirectory().mkdirs() ) instanceLayout.getLogDirectory() ) ); if ( !instanceLayout.getRunDirectory().exists() ) if ( !instanceLayout.getRunDirectory().mkdirs() ) instanceLayout.getRunDirectory() ) ); if ( !instanceLayout.getPartitionsDirectory().exists() ) if ( !instanceLayout.getPartitionsDirectory().mkdirs() ) instanceLayout.getPartitionsDirectory() ) ); if ( !instanceLayout.getConfDirectory().exists() ) if ( !instanceLayout.getConfDirectory().mkdirs() ) instanceLayout.getConfDirectory() ) );
/** * Gets the 'conf' directory ('<instance>/conf'). * * @return the 'conf' directory */ public File getConfDirectory() { if ( confDir == null ) { confDir = new File( getInstanceDirectory(), CONF_NAME ); } return confDir; }
SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ); File confDir = dirService.getInstanceLayout().getConfDirectory(); File ksFile = new File( confDir, "httpserver.generated.ks" ); File webAppDir = new File( dirService.getInstanceLayout().getInstanceDirectory(), "webapps" );
lockFile = new RandomAccessFile( new File( instanceLayout.getInstanceDirectory(), LOCK_FILE_NAME ), "rw" ); try String message = "the working directory " + instanceLayout.getRunDirectory() + " has been locked by another directory service."; LOG.error( message );
/** * Gets the log configuration file (<em>'<instance>/conf/log4j.properties'</em>). * * @return the log configuration file */ public File getLogConfigurationFile() { return new File( getConfDirectory(), LOG4J_PROPERTIES ); }
File configFile = new File( layout.getConfDirectory(), DIRECTORY_CACHESERVICE_XML ); cachePath = layout.getCacheDirectory().getAbsolutePath();
private static int readShutdownPort( InstanceLayout layout ) throws IOException { return Integer.parseInt( new String( Files.readAllBytes( Paths.get( layout.getRunDirectory().getAbsolutePath(), ".shutdown.port" ) ), Charset.forName( "utf-8" ) ) ); }
/** * Initialize the interceptor */ @Override public void init( DirectoryService service ) throws IOException { if ( workingDirectory == null ) { workingDirectory = service.getInstanceLayout().getLogDirectory(); } /** Load or create the journal file */ if ( fileName == null ) { fileName = "journal.ldif"; } journal = new File( workingDirectory, fileName ); // The new requests are added at the end of the existing journal writer = new PrintWriter( new OutputStreamWriter( Files.newOutputStream( journal.toPath(), StandardOpenOption.APPEND ) ) ); }
private void initDirectoryService() throws Exception { ds = new DefaultDirectoryService(); ds.setInstanceLayout(new InstanceLayout(workDir)); instanceLayout.getPartitionsDirectory(), "schema"); SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory()); extractor.extractOrCopy(); systemPartition.setId("system"); systemPartition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI()); systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN)); partition.setId(orgName); partition.setPartitionPath(new File( ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI()); partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain)); ds.addPartition(partition);
InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
/** * Build the working directory */ private void buildInstanceDirectory( String name ) throws IOException { String instanceDirectory = System.getProperty( "workingDirectory" ); if ( instanceDirectory == null ) { instanceDirectory = System.getProperty( "java.io.tmpdir" ) + "/server-work-" + name; } InstanceLayout instanceLayout = new InstanceLayout( instanceDirectory ); if ( instanceLayout.getInstanceDirectory().exists() ) { try { FileUtils.deleteDirectory( instanceLayout.getInstanceDirectory() ); } catch ( IOException e ) { LOG.warn( "couldn't delete the instance directory before initializing the DirectoryService", e ); } } directoryService.setInstanceLayout( instanceLayout ); }
/** * Gets the 'partitions' directory ('<instance>/partitions') * * @return the 'partitions' directory */ public File getPartitionsDirectory() { if ( partitionsDir == null ) { partitionsDir = new File( getInstanceDirectory(), PARTITIONS_NAME ); } return partitionsDir; }
/** * Gets the wrapper configuration file (<em>'<instance>/conf/wrapper.conf'</em>). * * @return the wrapper configuration file */ public File getWrapperConfigurationFile() { return new File( getConfDirectory(), WRAPPER_CONF ); }