001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.admin.std.meta; 028 029 030 031 import java.util.Collection; 032 import org.opends.server.admin.AdministratorAction; 033 import org.opends.server.admin.BooleanPropertyDefinition; 034 import org.opends.server.admin.ClassPropertyDefinition; 035 import org.opends.server.admin.client.AuthorizationException; 036 import org.opends.server.admin.client.CommunicationException; 037 import org.opends.server.admin.client.ConcurrentModificationException; 038 import org.opends.server.admin.client.IllegalManagedObjectNameException; 039 import org.opends.server.admin.client.ManagedObject; 040 import org.opends.server.admin.client.ManagedObjectDecodingException; 041 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 042 import org.opends.server.admin.client.OperationRejectedException; 043 import org.opends.server.admin.DefaultBehaviorException; 044 import org.opends.server.admin.DefaultBehaviorProvider; 045 import org.opends.server.admin.DefinedDefaultBehaviorProvider; 046 import org.opends.server.admin.DefinitionDecodingException; 047 import org.opends.server.admin.InstantiableRelationDefinition; 048 import org.opends.server.admin.IntegerPropertyDefinition; 049 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 050 import org.opends.server.admin.ManagedObjectDefinition; 051 import org.opends.server.admin.ManagedObjectNotFoundException; 052 import org.opends.server.admin.OptionalRelationDefinition; 053 import org.opends.server.admin.PropertyOption; 054 import org.opends.server.admin.PropertyProvider; 055 import org.opends.server.admin.server.ConfigurationAddListener; 056 import org.opends.server.admin.server.ConfigurationChangeListener; 057 import org.opends.server.admin.server.ConfigurationDeleteListener; 058 import org.opends.server.admin.server.ServerManagedObject; 059 import org.opends.server.admin.std.client.ReplicationDomainCfgClient; 060 import org.opends.server.admin.std.client.ReplicationServerCfgClient; 061 import org.opends.server.admin.std.client.ReplicationSynchronizationProviderCfgClient; 062 import org.opends.server.admin.std.server.ReplicationDomainCfg; 063 import org.opends.server.admin.std.server.ReplicationServerCfg; 064 import org.opends.server.admin.std.server.ReplicationSynchronizationProviderCfg; 065 import org.opends.server.admin.std.server.SynchronizationProviderCfg; 066 import org.opends.server.admin.Tag; 067 import org.opends.server.config.ConfigException; 068 import org.opends.server.types.DN; 069 070 071 072 /** 073 * An interface for querying the Replication Synchronization Provider 074 * managed object definition meta information. 075 * <p> 076 * The Replication Synchronization Provider provides multi-master 077 * replication of data across multiple Directory Server instances. 078 */ 079 public final class ReplicationSynchronizationProviderCfgDefn extends ManagedObjectDefinition<ReplicationSynchronizationProviderCfgClient, ReplicationSynchronizationProviderCfg> { 080 081 // The singleton configuration definition instance. 082 private static final ReplicationSynchronizationProviderCfgDefn INSTANCE = new ReplicationSynchronizationProviderCfgDefn(); 083 084 085 086 // The "java-class" property definition. 087 private static final ClassPropertyDefinition PD_JAVA_CLASS; 088 089 090 091 // The "num-update-replay-threads" property definition. 092 private static final IntegerPropertyDefinition PD_NUM_UPDATE_REPLAY_THREADS; 093 094 095 096 // The "replication-domains" relation definition. 097 private static final InstantiableRelationDefinition<ReplicationDomainCfgClient, ReplicationDomainCfg> RD_REPLICATION_DOMAINS; 098 099 100 101 // The "replication-server" relation definition. 102 private static final OptionalRelationDefinition<ReplicationServerCfgClient, ReplicationServerCfg> RD_REPLICATION_SERVER; 103 104 105 106 // Build the "java-class" property definition. 107 static { 108 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 109 builder.setOption(PropertyOption.MANDATORY); 110 builder.setOption(PropertyOption.ADVANCED); 111 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 112 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.replication.plugin.MultimasterReplication"); 113 builder.setDefaultBehaviorProvider(provider); 114 builder.addInstanceOf("org.opends.server.api.SynchronizationProvider"); 115 PD_JAVA_CLASS = builder.getInstance(); 116 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 117 } 118 119 120 121 // Build the "num-update-replay-threads" property definition. 122 static { 123 IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "num-update-replay-threads"); 124 builder.setOption(PropertyOption.ADVANCED); 125 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "num-update-replay-threads")); 126 DefaultBehaviorProvider<Integer> provider = new DefinedDefaultBehaviorProvider<Integer>("10"); 127 builder.setDefaultBehaviorProvider(provider); 128 builder.setUpperLimit(65535); 129 builder.setLowerLimit(1); 130 PD_NUM_UPDATE_REPLAY_THREADS = builder.getInstance(); 131 INSTANCE.registerPropertyDefinition(PD_NUM_UPDATE_REPLAY_THREADS); 132 } 133 134 135 136 // Build the "replication-domains" relation definition. 137 static { 138 InstantiableRelationDefinition.Builder<ReplicationDomainCfgClient, ReplicationDomainCfg> builder = 139 new InstantiableRelationDefinition.Builder<ReplicationDomainCfgClient, ReplicationDomainCfg>(INSTANCE, "replication-domain", "replication-domains", ReplicationDomainCfgDefn.getInstance()); 140 RD_REPLICATION_DOMAINS = builder.getInstance(); 141 INSTANCE.registerRelationDefinition(RD_REPLICATION_DOMAINS); 142 } 143 144 145 146 // Build the "replication-server" relation definition. 147 static { 148 OptionalRelationDefinition.Builder<ReplicationServerCfgClient, ReplicationServerCfg> builder = 149 new OptionalRelationDefinition.Builder<ReplicationServerCfgClient, ReplicationServerCfg>(INSTANCE, "replication-server", ReplicationServerCfgDefn.getInstance()); 150 RD_REPLICATION_SERVER = builder.getInstance(); 151 INSTANCE.registerRelationDefinition(RD_REPLICATION_SERVER); 152 } 153 154 155 156 // Register the tags associated with this managed object definition. 157 static { 158 INSTANCE.registerTag(Tag.valueOf("replication")); 159 } 160 161 162 163 /** 164 * Get the Replication Synchronization Provider configuration 165 * definition singleton. 166 * 167 * @return Returns the Replication Synchronization Provider 168 * configuration definition singleton. 169 */ 170 public static ReplicationSynchronizationProviderCfgDefn getInstance() { 171 return INSTANCE; 172 } 173 174 175 176 /** 177 * Private constructor. 178 */ 179 private ReplicationSynchronizationProviderCfgDefn() { 180 super("replication-synchronization-provider", SynchronizationProviderCfgDefn.getInstance()); 181 } 182 183 184 185 /** 186 * {@inheritDoc} 187 */ 188 public ReplicationSynchronizationProviderCfgClient createClientConfiguration( 189 ManagedObject<? extends ReplicationSynchronizationProviderCfgClient> impl) { 190 return new ReplicationSynchronizationProviderCfgClientImpl(impl); 191 } 192 193 194 195 /** 196 * {@inheritDoc} 197 */ 198 public ReplicationSynchronizationProviderCfg createServerConfiguration( 199 ServerManagedObject<? extends ReplicationSynchronizationProviderCfg> impl) { 200 return new ReplicationSynchronizationProviderCfgServerImpl(impl); 201 } 202 203 204 205 /** 206 * {@inheritDoc} 207 */ 208 public Class<ReplicationSynchronizationProviderCfg> getServerConfigurationClass() { 209 return ReplicationSynchronizationProviderCfg.class; 210 } 211 212 213 214 /** 215 * Get the "enabled" property definition. 216 * <p> 217 * Indicates whether the Replication Synchronization Provider is 218 * enabled for use. 219 * 220 * @return Returns the "enabled" property definition. 221 */ 222 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 223 return SynchronizationProviderCfgDefn.getInstance().getEnabledPropertyDefinition(); 224 } 225 226 227 228 /** 229 * Get the "java-class" property definition. 230 * <p> 231 * Specifies the fully-qualified name of the Java class that 232 * provides the Replication Synchronization Provider implementation. 233 * 234 * @return Returns the "java-class" property definition. 235 */ 236 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 237 return PD_JAVA_CLASS; 238 } 239 240 241 242 /** 243 * Get the "num-update-replay-threads" property definition. 244 * <p> 245 * Specifies the number of update replay threads. 246 * <p> 247 * This value is the number of threads created for replaying every 248 * updates received for all the replication domains. 249 * 250 * @return Returns the "num-update-replay-threads" property definition. 251 */ 252 public IntegerPropertyDefinition getNumUpdateReplayThreadsPropertyDefinition() { 253 return PD_NUM_UPDATE_REPLAY_THREADS; 254 } 255 256 257 258 /** 259 * Get the "replication-domains" relation definition. 260 * 261 * @return Returns the "replication-domains" relation definition. 262 */ 263 public InstantiableRelationDefinition<ReplicationDomainCfgClient,ReplicationDomainCfg> getReplicationDomainsRelationDefinition() { 264 return RD_REPLICATION_DOMAINS; 265 } 266 267 268 269 /** 270 * Get the "replication-server" relation definition. 271 * 272 * @return Returns the "replication-server" relation definition. 273 */ 274 public OptionalRelationDefinition<ReplicationServerCfgClient,ReplicationServerCfg> getReplicationServerRelationDefinition() { 275 return RD_REPLICATION_SERVER; 276 } 277 278 279 280 /** 281 * Managed object client implementation. 282 */ 283 private static class ReplicationSynchronizationProviderCfgClientImpl implements 284 ReplicationSynchronizationProviderCfgClient { 285 286 // Private implementation. 287 private ManagedObject<? extends ReplicationSynchronizationProviderCfgClient> impl; 288 289 290 291 // Private constructor. 292 private ReplicationSynchronizationProviderCfgClientImpl( 293 ManagedObject<? extends ReplicationSynchronizationProviderCfgClient> impl) { 294 this.impl = impl; 295 } 296 297 298 299 /** 300 * {@inheritDoc} 301 */ 302 public Boolean isEnabled() { 303 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 304 } 305 306 307 308 /** 309 * {@inheritDoc} 310 */ 311 public void setEnabled(boolean value) { 312 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 313 } 314 315 316 317 /** 318 * {@inheritDoc} 319 */ 320 public String getJavaClass() { 321 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 322 } 323 324 325 326 /** 327 * {@inheritDoc} 328 */ 329 public void setJavaClass(String value) { 330 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 331 } 332 333 334 335 /** 336 * {@inheritDoc} 337 */ 338 public int getNumUpdateReplayThreads() { 339 return impl.getPropertyValue(INSTANCE.getNumUpdateReplayThreadsPropertyDefinition()); 340 } 341 342 343 344 /** 345 * {@inheritDoc} 346 */ 347 public void setNumUpdateReplayThreads(Integer value) { 348 impl.setPropertyValue(INSTANCE.getNumUpdateReplayThreadsPropertyDefinition(), value); 349 } 350 351 352 353 /** 354 * {@inheritDoc} 355 */ 356 public String[] listReplicationDomains() throws ConcurrentModificationException, 357 AuthorizationException, CommunicationException { 358 return impl.listChildren(INSTANCE.getReplicationDomainsRelationDefinition()); 359 } 360 361 362 363 /** 364 * {@inheritDoc} 365 */ 366 public ReplicationDomainCfgClient getReplicationDomain(String name) 367 throws DefinitionDecodingException, ManagedObjectDecodingException, 368 ManagedObjectNotFoundException, ConcurrentModificationException, 369 AuthorizationException, CommunicationException { 370 return impl.getChild(INSTANCE.getReplicationDomainsRelationDefinition(), name).getConfiguration(); 371 } 372 373 374 375 /** 376 * {@inheritDoc} 377 */ 378 public <M extends ReplicationDomainCfgClient> M createReplicationDomain( 379 ManagedObjectDefinition<M, ? extends ReplicationDomainCfg> d, String name, Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException { 380 return impl.createChild(INSTANCE.getReplicationDomainsRelationDefinition(), d, name, exceptions).getConfiguration(); 381 } 382 383 384 385 /** 386 * {@inheritDoc} 387 */ 388 public void removeReplicationDomain(String name) 389 throws ManagedObjectNotFoundException, ConcurrentModificationException, 390 OperationRejectedException, AuthorizationException, CommunicationException { 391 impl.removeChild(INSTANCE.getReplicationDomainsRelationDefinition(), name); 392 } 393 394 395 396 /** 397 * {@inheritDoc} 398 */ 399 public boolean hasReplicationServer() throws ConcurrentModificationException, 400 AuthorizationException, CommunicationException { 401 return impl.hasChild(INSTANCE.getReplicationServerRelationDefinition()); 402 } 403 404 405 406 /** 407 * {@inheritDoc} 408 */ 409 public ReplicationServerCfgClient getReplicationServer() 410 throws DefinitionDecodingException, ManagedObjectDecodingException, 411 ManagedObjectNotFoundException, ConcurrentModificationException, 412 AuthorizationException, CommunicationException { 413 return impl.getChild(INSTANCE.getReplicationServerRelationDefinition()).getConfiguration(); 414 } 415 416 417 418 /** 419 * {@inheritDoc} 420 */ 421 public <M extends ReplicationServerCfgClient> M createReplicationServer( 422 ManagedObjectDefinition<M, ? extends ReplicationServerCfg> d, Collection<DefaultBehaviorException> exceptions) { 423 return impl.createChild(INSTANCE.getReplicationServerRelationDefinition(), d, exceptions).getConfiguration(); 424 } 425 426 427 428 /** 429 * {@inheritDoc} 430 */ 431 public void removeReplicationServer() 432 throws ManagedObjectNotFoundException, ConcurrentModificationException, 433 OperationRejectedException, AuthorizationException, CommunicationException { 434 impl.removeChild(INSTANCE.getReplicationServerRelationDefinition()); 435 } 436 437 438 439 /** 440 * {@inheritDoc} 441 */ 442 public ManagedObjectDefinition<? extends ReplicationSynchronizationProviderCfgClient, ? extends ReplicationSynchronizationProviderCfg> definition() { 443 return INSTANCE; 444 } 445 446 447 448 /** 449 * {@inheritDoc} 450 */ 451 public PropertyProvider properties() { 452 return impl; 453 } 454 455 456 457 /** 458 * {@inheritDoc} 459 */ 460 public void commit() throws ManagedObjectAlreadyExistsException, 461 MissingMandatoryPropertiesException, ConcurrentModificationException, 462 OperationRejectedException, AuthorizationException, 463 CommunicationException { 464 impl.commit(); 465 } 466 467 } 468 469 470 471 /** 472 * Managed object server implementation. 473 */ 474 private static class ReplicationSynchronizationProviderCfgServerImpl implements 475 ReplicationSynchronizationProviderCfg { 476 477 // Private implementation. 478 private ServerManagedObject<? extends ReplicationSynchronizationProviderCfg> impl; 479 480 // The value of the "enabled" property. 481 private final boolean pEnabled; 482 483 // The value of the "java-class" property. 484 private final String pJavaClass; 485 486 // The value of the "num-update-replay-threads" property. 487 private final int pNumUpdateReplayThreads; 488 489 490 491 // Private constructor. 492 private ReplicationSynchronizationProviderCfgServerImpl(ServerManagedObject<? extends ReplicationSynchronizationProviderCfg> impl) { 493 this.impl = impl; 494 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 495 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 496 this.pNumUpdateReplayThreads = impl.getPropertyValue(INSTANCE.getNumUpdateReplayThreadsPropertyDefinition()); 497 } 498 499 500 501 /** 502 * {@inheritDoc} 503 */ 504 public void addReplicationChangeListener( 505 ConfigurationChangeListener<ReplicationSynchronizationProviderCfg> listener) { 506 impl.registerChangeListener(listener); 507 } 508 509 510 511 /** 512 * {@inheritDoc} 513 */ 514 public void removeReplicationChangeListener( 515 ConfigurationChangeListener<ReplicationSynchronizationProviderCfg> listener) { 516 impl.deregisterChangeListener(listener); 517 } 518 /** 519 * {@inheritDoc} 520 */ 521 public void addChangeListener( 522 ConfigurationChangeListener<SynchronizationProviderCfg> listener) { 523 impl.registerChangeListener(listener); 524 } 525 526 527 528 /** 529 * {@inheritDoc} 530 */ 531 public void removeChangeListener( 532 ConfigurationChangeListener<SynchronizationProviderCfg> listener) { 533 impl.deregisterChangeListener(listener); 534 } 535 536 537 538 /** 539 * {@inheritDoc} 540 */ 541 public boolean isEnabled() { 542 return pEnabled; 543 } 544 545 546 547 /** 548 * {@inheritDoc} 549 */ 550 public String getJavaClass() { 551 return pJavaClass; 552 } 553 554 555 556 /** 557 * {@inheritDoc} 558 */ 559 public int getNumUpdateReplayThreads() { 560 return pNumUpdateReplayThreads; 561 } 562 563 564 565 /** 566 * {@inheritDoc} 567 */ 568 public String[] listReplicationDomains() { 569 return impl.listChildren(INSTANCE.getReplicationDomainsRelationDefinition()); 570 } 571 572 573 574 /** 575 * {@inheritDoc} 576 */ 577 public ReplicationDomainCfg getReplicationDomain(String name) throws ConfigException { 578 return impl.getChild(INSTANCE.getReplicationDomainsRelationDefinition(), name).getConfiguration(); 579 } 580 581 582 583 /** 584 * {@inheritDoc} 585 */ 586 public void addReplicationDomainAddListener( 587 ConfigurationAddListener<ReplicationDomainCfg> listener) throws ConfigException { 588 impl.registerAddListener(INSTANCE.getReplicationDomainsRelationDefinition(), listener); 589 } 590 591 592 593 /** 594 * {@inheritDoc} 595 */ 596 public void removeReplicationDomainAddListener( 597 ConfigurationAddListener<ReplicationDomainCfg> listener) { 598 impl.deregisterAddListener(INSTANCE.getReplicationDomainsRelationDefinition(), listener); 599 } 600 601 602 603 /** 604 * {@inheritDoc} 605 */ 606 public void addReplicationDomainDeleteListener( 607 ConfigurationDeleteListener<ReplicationDomainCfg> listener) throws ConfigException { 608 impl.registerDeleteListener(INSTANCE.getReplicationDomainsRelationDefinition(), listener); 609 } 610 611 612 613 /** 614 * {@inheritDoc} 615 */ 616 public void removeReplicationDomainDeleteListener( 617 ConfigurationDeleteListener<ReplicationDomainCfg> listener) { 618 impl.deregisterDeleteListener(INSTANCE.getReplicationDomainsRelationDefinition(), listener); 619 } 620 621 622 623 /** 624 * {@inheritDoc} 625 */ 626 public boolean hasReplicationServer() { 627 return impl.hasChild(INSTANCE.getReplicationServerRelationDefinition()); 628 } 629 630 631 632 /** 633 * {@inheritDoc} 634 */ 635 public ReplicationServerCfg getReplicationServer() throws ConfigException { 636 return impl.getChild(INSTANCE.getReplicationServerRelationDefinition()).getConfiguration(); 637 } 638 639 640 641 /** 642 * {@inheritDoc} 643 */ 644 public void addReplicationServerAddListener( 645 ConfigurationAddListener<ReplicationServerCfg> listener) throws ConfigException { 646 impl.registerAddListener(INSTANCE.getReplicationServerRelationDefinition(), listener); 647 } 648 649 650 651 /** 652 * {@inheritDoc} 653 */ 654 public void removeReplicationServerAddListener( 655 ConfigurationAddListener<ReplicationServerCfg> listener) { 656 impl.deregisterAddListener(INSTANCE.getReplicationServerRelationDefinition(), listener); 657 } 658 659 660 661 /** 662 * {@inheritDoc} 663 */ 664 public void addReplicationServerDeleteListener( 665 ConfigurationDeleteListener<ReplicationServerCfg> listener) throws ConfigException { 666 impl.registerDeleteListener(INSTANCE.getReplicationServerRelationDefinition(), listener); 667 } 668 669 670 671 /** 672 * {@inheritDoc} 673 */ 674 public void removeReplicationServerDeleteListener( 675 ConfigurationDeleteListener<ReplicationServerCfg> listener) { 676 impl.deregisterDeleteListener(INSTANCE.getReplicationServerRelationDefinition(), listener); 677 } 678 679 680 681 /** 682 * {@inheritDoc} 683 */ 684 public Class<? extends ReplicationSynchronizationProviderCfg> configurationClass() { 685 return ReplicationSynchronizationProviderCfg.class; 686 } 687 688 689 690 /** 691 * {@inheritDoc} 692 */ 693 public DN dn() { 694 return impl.getDN(); 695 } 696 697 } 698 }