001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008 Sun Microsystems, Inc.
015 */
016package org.forgerock.opendj.server.config.meta;
017
018
019
020import org.forgerock.opendj.config.AbstractManagedObjectDefinition;
021import org.forgerock.opendj.config.AdministratorAction;
022import org.forgerock.opendj.config.BooleanPropertyDefinition;
023import org.forgerock.opendj.config.ClassPropertyDefinition;
024import org.forgerock.opendj.config.DefaultBehaviorProvider;
025import org.forgerock.opendj.config.DefaultManagedObject;
026import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
027import org.forgerock.opendj.config.DNPropertyDefinition;
028import org.forgerock.opendj.config.DurationPropertyDefinition;
029import org.forgerock.opendj.config.EnumPropertyDefinition;
030import org.forgerock.opendj.config.InstantiableRelationDefinition;
031import org.forgerock.opendj.config.IntegerPropertyDefinition;
032import org.forgerock.opendj.config.PropertyOption;
033import org.forgerock.opendj.config.StringPropertyDefinition;
034import org.forgerock.opendj.config.Tag;
035import org.forgerock.opendj.ldap.DN;
036import org.forgerock.opendj.server.config.client.BackendIndexCfgClient;
037import org.forgerock.opendj.server.config.client.BackendVLVIndexCfgClient;
038import org.forgerock.opendj.server.config.client.PluggableBackendCfgClient;
039import org.forgerock.opendj.server.config.meta.BackendCfgDefn.WritabilityMode;
040import org.forgerock.opendj.server.config.meta.BackendIndexCfgDefn;
041import org.forgerock.opendj.server.config.server.BackendIndexCfg;
042import org.forgerock.opendj.server.config.server.BackendVLVIndexCfg;
043import org.forgerock.opendj.server.config.server.PluggableBackendCfg;
044
045
046
047/**
048 * An interface for querying the Pluggable Backend managed object
049 * definition meta information.
050 * <p>
051 * A Pluggable Backend stores application data in a pluggable
052 * database.
053 */
054public final class PluggableBackendCfgDefn extends AbstractManagedObjectDefinition<PluggableBackendCfgClient, PluggableBackendCfg> {
055
056  /** The singleton configuration definition instance. */
057  private static final PluggableBackendCfgDefn INSTANCE = new PluggableBackendCfgDefn();
058
059
060
061  /** The "compact-encoding" property definition. */
062  private static final BooleanPropertyDefinition PD_COMPACT_ENCODING;
063
064
065
066  /** The "entries-compressed" property definition. */
067  private static final BooleanPropertyDefinition PD_ENTRIES_COMPRESSED;
068
069
070
071  /** The "index-entry-limit" property definition. */
072  private static final IntegerPropertyDefinition PD_INDEX_ENTRY_LIMIT;
073
074
075
076  /** The "index-filter-analyzer-enabled" property definition. */
077  private static final BooleanPropertyDefinition PD_INDEX_FILTER_ANALYZER_ENABLED;
078
079
080
081  /** The "index-filter-analyzer-max-filters" property definition. */
082  private static final IntegerPropertyDefinition PD_INDEX_FILTER_ANALYZER_MAX_FILTERS;
083
084
085
086  /** The "preload-time-limit" property definition. */
087  private static final DurationPropertyDefinition PD_PRELOAD_TIME_LIMIT;
088
089
090
091  /** The "writability-mode" property definition. */
092  private static final EnumPropertyDefinition<WritabilityMode> PD_WRITABILITY_MODE;
093
094
095
096  /** The "backend-indexes" relation definition. */
097  private static final InstantiableRelationDefinition<BackendIndexCfgClient, BackendIndexCfg> RD_BACKEND_INDEXES;
098
099
100
101  /** The "backend-vlv-indexes" relation definition. */
102  private static final InstantiableRelationDefinition<BackendVLVIndexCfgClient, BackendVLVIndexCfg> RD_BACKEND_VLV_INDEXES;
103
104
105
106  /** Build the "compact-encoding" property definition. */
107  static {
108      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "compact-encoding");
109      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "compact-encoding"));
110      DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("true");
111      builder.setDefaultBehaviorProvider(provider);
112      PD_COMPACT_ENCODING = builder.getInstance();
113      INSTANCE.registerPropertyDefinition(PD_COMPACT_ENCODING);
114  }
115
116
117
118  /** Build the "entries-compressed" property definition. */
119  static {
120      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "entries-compressed");
121      builder.setOption(PropertyOption.ADVANCED);
122      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "entries-compressed"));
123      DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
124      builder.setDefaultBehaviorProvider(provider);
125      PD_ENTRIES_COMPRESSED = builder.getInstance();
126      INSTANCE.registerPropertyDefinition(PD_ENTRIES_COMPRESSED);
127  }
128
129
130
131  /** Build the "index-entry-limit" property definition. */
132  static {
133      IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "index-entry-limit");
134      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "index-entry-limit"));
135      DefaultBehaviorProvider<Integer> provider = new DefinedDefaultBehaviorProvider<Integer>("4000");
136      builder.setDefaultBehaviorProvider(provider);
137      builder.setUpperLimit(2147483647);
138      builder.setLowerLimit(0);
139      PD_INDEX_ENTRY_LIMIT = builder.getInstance();
140      INSTANCE.registerPropertyDefinition(PD_INDEX_ENTRY_LIMIT);
141  }
142
143
144
145  /** Build the "index-filter-analyzer-enabled" property definition. */
146  static {
147      BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "index-filter-analyzer-enabled");
148      builder.setOption(PropertyOption.ADVANCED);
149      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "index-filter-analyzer-enabled"));
150      DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
151      builder.setDefaultBehaviorProvider(provider);
152      PD_INDEX_FILTER_ANALYZER_ENABLED = builder.getInstance();
153      INSTANCE.registerPropertyDefinition(PD_INDEX_FILTER_ANALYZER_ENABLED);
154  }
155
156
157
158  /** Build the "index-filter-analyzer-max-filters" property definition. */
159  static {
160      IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "index-filter-analyzer-max-filters");
161      builder.setOption(PropertyOption.ADVANCED);
162      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "index-filter-analyzer-max-filters"));
163      DefaultBehaviorProvider<Integer> provider = new DefinedDefaultBehaviorProvider<Integer>("25");
164      builder.setDefaultBehaviorProvider(provider);
165      builder.setLowerLimit(1);
166      PD_INDEX_FILTER_ANALYZER_MAX_FILTERS = builder.getInstance();
167      INSTANCE.registerPropertyDefinition(PD_INDEX_FILTER_ANALYZER_MAX_FILTERS);
168  }
169
170
171
172  /** Build the "preload-time-limit" property definition. */
173  static {
174      DurationPropertyDefinition.Builder builder = DurationPropertyDefinition.createBuilder(INSTANCE, "preload-time-limit");
175      builder.setOption(PropertyOption.ADVANCED);
176      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "preload-time-limit"));
177      DefaultBehaviorProvider<Long> provider = new DefinedDefaultBehaviorProvider<Long>("0s");
178      builder.setDefaultBehaviorProvider(provider);
179      builder.setBaseUnit("ms");
180      builder.setUpperLimit("2147483647");
181      builder.setLowerLimit("0");
182      PD_PRELOAD_TIME_LIMIT = builder.getInstance();
183      INSTANCE.registerPropertyDefinition(PD_PRELOAD_TIME_LIMIT);
184  }
185
186
187
188  /** Build the "writability-mode" property definition. */
189  static {
190      EnumPropertyDefinition.Builder<WritabilityMode> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "writability-mode");
191      builder.setOption(PropertyOption.MANDATORY);
192      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "writability-mode"));
193      DefaultBehaviorProvider<WritabilityMode> provider = new DefinedDefaultBehaviorProvider<WritabilityMode>("enabled");
194      builder.setDefaultBehaviorProvider(provider);
195      builder.setEnumClass(WritabilityMode.class);
196      PD_WRITABILITY_MODE = builder.getInstance();
197      INSTANCE.registerPropertyDefinition(PD_WRITABILITY_MODE);
198  }
199
200
201
202  // Build the "backend-indexes" relation definition.
203  static {
204    InstantiableRelationDefinition.Builder<BackendIndexCfgClient, BackendIndexCfg> builder =
205      new InstantiableRelationDefinition.Builder<BackendIndexCfgClient, BackendIndexCfg>(INSTANCE, "backend-index", "backend-indexes", BackendIndexCfgDefn.getInstance());
206    builder.setNamingProperty(BackendIndexCfgDefn.getInstance().getAttributePropertyDefinition());
207    {
208      DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg> dmoBuilder = new DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg>(BackendIndexCfgDefn.getInstance());
209      dmoBuilder.setPropertyValues("index-type", "presence");
210      dmoBuilder.setPropertyValues("attribute", "aci");
211      builder.setDefaultManagedObject("aci", dmoBuilder.getInstance());
212    }
213    {
214      DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg> dmoBuilder = new DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg>(BackendIndexCfgDefn.getInstance());
215      dmoBuilder.setPropertyValues("index-type", "equality");
216      dmoBuilder.setPropertyValues("attribute", "entryUUID");
217      builder.setDefaultManagedObject("entryUUID", dmoBuilder.getInstance());
218    }
219    {
220      DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg> dmoBuilder = new DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg>(BackendIndexCfgDefn.getInstance());
221      dmoBuilder.setPropertyValues("index-type", "equality");
222      dmoBuilder.setPropertyValues("attribute", "objectClass");
223      builder.setDefaultManagedObject("objectClass", dmoBuilder.getInstance());
224    }
225    {
226      DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg> dmoBuilder = new DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg>(BackendIndexCfgDefn.getInstance());
227      dmoBuilder.setPropertyValues("index-type", "ordering");
228      dmoBuilder.setPropertyValues("attribute", "ds-sync-hist");
229      builder.setDefaultManagedObject("ds-sync-hist", dmoBuilder.getInstance());
230    }
231    {
232      DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg> dmoBuilder = new DefaultManagedObject.Builder<BackendIndexCfgClient, BackendIndexCfg>(BackendIndexCfgDefn.getInstance());
233      dmoBuilder.setPropertyValues("index-type", "equality");
234      dmoBuilder.setPropertyValues("attribute", "ds-sync-conflict");
235      builder.setDefaultManagedObject("ds-sync-conflict", dmoBuilder.getInstance());
236    }
237    RD_BACKEND_INDEXES = builder.getInstance();
238    INSTANCE.registerRelationDefinition(RD_BACKEND_INDEXES);
239  }
240
241
242
243  // Build the "backend-vlv-indexes" relation definition.
244  static {
245    InstantiableRelationDefinition.Builder<BackendVLVIndexCfgClient, BackendVLVIndexCfg> builder =
246      new InstantiableRelationDefinition.Builder<BackendVLVIndexCfgClient, BackendVLVIndexCfg>(INSTANCE, "backend-vlv-index", "backend-vlv-indexes", BackendVLVIndexCfgDefn.getInstance());
247    builder.setNamingProperty(BackendVLVIndexCfgDefn.getInstance().getNamePropertyDefinition());
248    RD_BACKEND_VLV_INDEXES = builder.getInstance();
249    INSTANCE.registerRelationDefinition(RD_BACKEND_VLV_INDEXES);
250  }
251
252
253
254  // Register the tags associated with this managed object definition.
255  static {
256    INSTANCE.registerTag(Tag.valueOf("database"));
257  }
258
259
260
261  /**
262   * Get the Pluggable Backend configuration definition singleton.
263   *
264   * @return Returns the Pluggable Backend configuration definition
265   *         singleton.
266   */
267  public static PluggableBackendCfgDefn getInstance() {
268    return INSTANCE;
269  }
270
271
272
273  /**
274   * Private constructor.
275   */
276  private PluggableBackendCfgDefn() {
277    super("pluggable-backend", BackendCfgDefn.getInstance());
278  }
279
280
281
282  /**
283   * Get the "backend-id" property definition.
284   * <p>
285   * Specifies a name to identify the associated backend.
286   * <p>
287   * The name must be unique among all backends in the server. The
288   * backend ID may not be altered after the backend is created in the
289   * server.
290   *
291   * @return Returns the "backend-id" property definition.
292   */
293  public StringPropertyDefinition getBackendIdPropertyDefinition() {
294    return BackendCfgDefn.getInstance().getBackendIdPropertyDefinition();
295  }
296
297
298
299  /**
300   * Get the "base-dn" property definition.
301   * <p>
302   * Specifies the base DN(s) for the data that the backend handles.
303   * <p>
304   * A single backend may be responsible for one or more base DNs.
305   * Note that no two backends may have the same base DN although one
306   * backend may have a base DN that is below a base DN provided by
307   * another backend (similar to the use of sub-suffixes in the Sun
308   * Java System Directory Server). If any of the base DNs is
309   * subordinate to a base DN for another backend, then all base DNs
310   * for that backend must be subordinate to that same base DN.
311   *
312   * @return Returns the "base-dn" property definition.
313   */
314  public DNPropertyDefinition getBaseDNPropertyDefinition() {
315    return BackendCfgDefn.getInstance().getBaseDNPropertyDefinition();
316  }
317
318
319
320  /**
321   * Get the "compact-encoding" property definition.
322   * <p>
323   * Indicates whether the backend should use a compact form when
324   * encoding entries by compressing the attribute descriptions and
325   * object class sets.
326   * <p>
327   * Note that this property applies only to the entries themselves
328   * and does not impact the index data.
329   *
330   * @return Returns the "compact-encoding" property definition.
331   */
332  public BooleanPropertyDefinition getCompactEncodingPropertyDefinition() {
333    return PD_COMPACT_ENCODING;
334  }
335
336
337
338  /**
339   * Get the "enabled" property definition.
340   * <p>
341   * Indicates whether the backend is enabled in the server.
342   * <p>
343   * If a backend is not enabled, then its contents are not accessible
344   * when processing operations.
345   *
346   * @return Returns the "enabled" property definition.
347   */
348  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
349    return BackendCfgDefn.getInstance().getEnabledPropertyDefinition();
350  }
351
352
353
354  /**
355   * Get the "entries-compressed" property definition.
356   * <p>
357   * Indicates whether the backend should attempt to compress entries
358   * before storing them in the database.
359   * <p>
360   * Note that this property applies only to the entries themselves
361   * and does not impact the index data. Further, the effectiveness of
362   * the compression is based on the type of data contained in the
363   * entry.
364   *
365   * @return Returns the "entries-compressed" property definition.
366   */
367  public BooleanPropertyDefinition getEntriesCompressedPropertyDefinition() {
368    return PD_ENTRIES_COMPRESSED;
369  }
370
371
372
373  /**
374   * Get the "index-entry-limit" property definition.
375   * <p>
376   * Specifies the maximum number of entries that is allowed to match
377   * a given index key before that particular index key is no longer
378   * maintained.
379   * <p>
380   * This property is analogous to the ALL IDs threshold in the Sun
381   * Java System Directory Server. Note that this is the default limit
382   * for the backend, and it may be overridden on a per-attribute
383   * basis.A value of 0 means there is no limit.
384   *
385   * @return Returns the "index-entry-limit" property definition.
386   */
387  public IntegerPropertyDefinition getIndexEntryLimitPropertyDefinition() {
388    return PD_INDEX_ENTRY_LIMIT;
389  }
390
391
392
393  /**
394   * Get the "index-filter-analyzer-enabled" property definition.
395   * <p>
396   * Indicates whether to gather statistical information about the
397   * search filters processed by the directory server while evaluating
398   * the usage of indexes.
399   * <p>
400   * Analyzing indexes requires gathering search filter usage patterns
401   * from user requests, especially for values as specified in the
402   * filters and subsequently looking the status of those values into
403   * the index files. When a search requests is processed, internal or
404   * user generated, a first phase uses indexes to find potential
405   * entries to be returned. Depending on the search filter, if the
406   * index of one of the specified attributes matches too many entries
407   * (exceeds the index entry limit), the search becomes non-indexed.
408   * In any case, all entries thus gathered (or the entire DIT) are
409   * matched against the filter for actually returning the search
410   * result.
411   *
412   * @return Returns the "index-filter-analyzer-enabled" property definition.
413   */
414  public BooleanPropertyDefinition getIndexFilterAnalyzerEnabledPropertyDefinition() {
415    return PD_INDEX_FILTER_ANALYZER_ENABLED;
416  }
417
418
419
420  /**
421   * Get the "index-filter-analyzer-max-filters" property definition.
422   * <p>
423   * The maximum number of search filter statistics to keep.
424   * <p>
425   * When the maximum number of search filter is reached, the least
426   * used one will be deleted.
427   *
428   * @return Returns the "index-filter-analyzer-max-filters" property definition.
429   */
430  public IntegerPropertyDefinition getIndexFilterAnalyzerMaxFiltersPropertyDefinition() {
431    return PD_INDEX_FILTER_ANALYZER_MAX_FILTERS;
432  }
433
434
435
436  /**
437   * Get the "java-class" property definition.
438   * <p>
439   * Specifies the fully-qualified name of the Java class that
440   * provides the backend implementation.
441   *
442   * @return Returns the "java-class" property definition.
443   */
444  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
445    return BackendCfgDefn.getInstance().getJavaClassPropertyDefinition();
446  }
447
448
449
450  /**
451   * Get the "preload-time-limit" property definition.
452   * <p>
453   * Specifies the length of time that the backend is allowed to spend
454   * "pre-loading" data when it is initialized.
455   * <p>
456   * The pre-load process is used to pre-populate the database cache,
457   * so that it can be more quickly available when the server is
458   * processing requests. A duration of zero means there is no
459   * pre-load.
460   *
461   * @return Returns the "preload-time-limit" property definition.
462   */
463  public DurationPropertyDefinition getPreloadTimeLimitPropertyDefinition() {
464    return PD_PRELOAD_TIME_LIMIT;
465  }
466
467
468
469  /**
470   * Get the "writability-mode" property definition.
471   * <p>
472   * Specifies the behavior that the backend should use when
473   * processing write operations.
474   *
475   * @return Returns the "writability-mode" property definition.
476   */
477  public EnumPropertyDefinition<WritabilityMode> getWritabilityModePropertyDefinition() {
478    return PD_WRITABILITY_MODE;
479  }
480
481
482
483  /**
484   * Get the "backend-indexes" relation definition.
485   *
486   * @return Returns the "backend-indexes" relation definition.
487   */
488  public InstantiableRelationDefinition<BackendIndexCfgClient,BackendIndexCfg> getBackendIndexesRelationDefinition() {
489    return RD_BACKEND_INDEXES;
490  }
491
492
493
494  /**
495   * Get the "backend-vlv-indexes" relation definition.
496   *
497   * @return Returns the "backend-vlv-indexes" relation definition.
498   */
499  public InstantiableRelationDefinition<BackendVLVIndexCfgClient,BackendVLVIndexCfg> getBackendVLVIndexesRelationDefinition() {
500    return RD_BACKEND_VLV_INDEXES;
501  }
502}