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 2006-2010 Sun Microsystems, Inc. 015 * Portions Copyright 2012-2016 ForgeRock AS. 016 */ 017package org.opends.server.protocols.ldap; 018 019import static org.opends.messages.ProtocolMessages.*; 020import static org.opends.server.protocols.ldap.LDAPConstants.*; 021import static org.opends.server.util.ServerConstants.*; 022 023import java.util.concurrent.atomic.AtomicLong; 024 025import org.forgerock.i18n.LocalizableMessage; 026import org.forgerock.opendj.config.server.ConfigException; 027import org.opends.server.admin.std.server.MonitorProviderCfg; 028import org.opends.server.api.MonitorData; 029import org.opends.server.api.MonitorProvider; 030import org.opends.server.types.DirectoryConfig; 031import org.opends.server.types.ObjectClass; 032import org.opends.server.types.OperationType; 033 034/** 035 * This class defines a data structure that will be used to keep track 036 * of various metrics related to LDAP communication that the server has 037 * conducted. The statistics that will be tracked include: 038 * <UL> 039 * <LI>The total number of LDAP client connections accepted by the 040 * server.</LI> 041 * <LI>The total number of LDAP client connections that have been 042 * closed.</LI> 043 * <LI>The total number of LDAP messages read, both overall and broken 044 * down by message type.</LI> 045 * <LI>The total number of LDAP messages written, both overall and 046 * broken down by message type.</LI> 047 * <LI>The total number of bytes read from LDAP clients.</LI> 048 * <LI>The total number of bytes written to LDAP clients.</LI> 049 * </UL> 050 * <BR> 051 * <BR> 052 * This class may also be used in a hierarchical form if it is desirable 053 * to get specific and general statistics at the same time (e.g., 054 * information about the interaction with a specific client or 055 * aggregated for all clients). 056 */ 057public class LDAPStatistics extends MonitorProvider<MonitorProviderCfg> 058{ 059 060 // The statistics maintained by this class. 061 private AtomicLong abandonRequests = new AtomicLong(0); 062 private AtomicLong addRequests = new AtomicLong(0); 063 private AtomicLong bindRequests = new AtomicLong(0); 064 private AtomicLong addResponses = new AtomicLong(0); 065 private AtomicLong bindResponses = new AtomicLong(0); 066 private AtomicLong bytesRead = new AtomicLong(0); 067 private AtomicLong bytesWritten = new AtomicLong(0); 068 private AtomicLong compareRequests = new AtomicLong(0); 069 private AtomicLong compareResponses = new AtomicLong(0); 070 private AtomicLong connectionsClosed = new AtomicLong(0); 071 private AtomicLong connectionsEstablished = new AtomicLong(0); 072 private AtomicLong deleteRequests = new AtomicLong(0); 073 private AtomicLong deleteResponses = new AtomicLong(0); 074 private AtomicLong extendedRequests = new AtomicLong(0); 075 private AtomicLong extendedResponses = new AtomicLong(0); 076 private AtomicLong messagesRead = new AtomicLong(0); 077 private AtomicLong messagesWritten = new AtomicLong(0); 078 private AtomicLong modifyRequests = new AtomicLong(0); 079 private AtomicLong modifyResponses = new AtomicLong(0); 080 private AtomicLong modifyDNRequests = new AtomicLong(0); 081 private AtomicLong modifyDNResponses = new AtomicLong(0); 082 private AtomicLong operationsAbandoned = new AtomicLong(0); 083 private AtomicLong operationsCompleted = new AtomicLong(0); 084 private AtomicLong operationsInitiated = new AtomicLong(0); 085 private AtomicLong searchRequests = new AtomicLong(0); 086 private AtomicLong searchOneRequests = new AtomicLong(0); 087 private AtomicLong searchSubRequests = new AtomicLong(0); 088 private AtomicLong searchResultEntries = new AtomicLong(0); 089 private AtomicLong searchResultReferences = new AtomicLong(0); 090 private AtomicLong searchResultsDone = new AtomicLong(0); 091 private AtomicLong unbindRequests = new AtomicLong(0); 092 093 094 /** The instance name for this monitor provider instance. */ 095 private final String instanceName; 096 097 // Monitor Objects : for Operations (count and time) 098 private AtomicLong addOperationCount = new AtomicLong(0); 099 private AtomicLong addOperationTime = new AtomicLong(0); 100 private AtomicLong searchOperationCount = new AtomicLong(0); 101 private AtomicLong searchOperationTime = new AtomicLong(0); 102 private AtomicLong delOperationCount = new AtomicLong(0); 103 private AtomicLong delOperationTime = new AtomicLong(0); 104 private AtomicLong bindOperationCount = new AtomicLong(0); 105 private AtomicLong bindOperationTime = new AtomicLong(0); 106 private AtomicLong unbindOperationCount = new AtomicLong(0); 107 private AtomicLong unbindOperationTime = new AtomicLong(0); 108 private AtomicLong compOperationCount = new AtomicLong(0); 109 private AtomicLong compOperationTime = new AtomicLong(0); 110 private AtomicLong modOperationCount = new AtomicLong(0); 111 private AtomicLong modOperationTime = new AtomicLong(0); 112 private AtomicLong moddnOperationCount = new AtomicLong(0); 113 private AtomicLong moddnOperationTime = new AtomicLong(0); 114 private AtomicLong abandonOperationCount = new AtomicLong(0); 115 private AtomicLong abandonOperationTime = new AtomicLong(0); 116 private AtomicLong extOperationCount = new AtomicLong(0); 117 private AtomicLong extOperationTime = new AtomicLong(0); 118 119 120 /** 121 * Creates a new instance of this class with the specified parent. 122 * 123 * @param instanceName 124 * The name for this monitor provider instance. 125 */ 126 public LDAPStatistics(String instanceName) 127 { 128 this.instanceName = instanceName; 129 } 130 131 132 133 /** {@inheritDoc} */ 134 @Override 135 public void initializeMonitorProvider(MonitorProviderCfg configuration) 136 throws ConfigException 137 { 138 // Throw an exception, because this monitor is not intended to be 139 // dynamically loaded from the configuration. Rather, it should be 140 // explicitly created and registered by the LDAP connection handler 141 // or an LDAP client connection. 142 LocalizableMessage message = 143 ERR_LDAP_STATS_INVALID_MONITOR_INITIALIZATION.get(configuration.dn()); 144 throw new ConfigException(message); 145 } 146 147 148 149 /** 150 * Retrieves the name of this monitor provider. It should be unique 151 * among all monitor providers, including all instances of the same 152 * monitor provider. 153 * 154 * @return The name of this monitor provider. 155 */ 156 @Override 157 public String getMonitorInstanceName() 158 { 159 return instanceName; 160 } 161 162 163 /** {@inheritDoc} */ 164 @Override 165 public ObjectClass getMonitorObjectClass() 166 { 167 return DirectoryConfig.getObjectClass(OC_MONITOR_CONNHANDLERSTATS, true); 168 } 169 170 @Override 171 public MonitorData getMonitorData() 172 { 173 // Construct the list of attributes to return. 174 /* TODO : the attribute names should be constant (in ServerConstants.java 175 * and associated with their objectclass 176 * OC_MONITOR_CONNHANDLERSTATS 177 */ 178 final MonitorData attrs = new MonitorData(31 + 10 * 2); 179 attrs.add("connectionsEstablished", connectionsEstablished); 180 attrs.add("connectionsClosed", connectionsClosed); 181 attrs.add("bytesRead", bytesRead); 182 attrs.add("bytesWritten", bytesWritten); 183 attrs.add("ldapMessagesRead", messagesRead); 184 attrs.add("ldapMessagesWritten", messagesWritten); 185 attrs.add("operationsAbandoned", operationsAbandoned); 186 attrs.add("operationsInitiated", operationsInitiated); 187 attrs.add("operationsCompleted", operationsCompleted); 188 attrs.add("abandonRequests", abandonRequests); 189 attrs.add("addRequests", addRequests); 190 attrs.add("addResponses", addResponses); 191 attrs.add("bindRequests", bindRequests); 192 attrs.add("bindResponses", bindResponses); 193 attrs.add("compareRequests", compareRequests); 194 attrs.add("compareResponses", compareResponses); 195 attrs.add("deleteRequests", deleteRequests); 196 attrs.add("deleteResponses", deleteResponses); 197 attrs.add("extendedRequests", extendedRequests); 198 attrs.add("extendedResponses", extendedResponses); 199 attrs.add("modifyRequests", modifyRequests); 200 attrs.add("modifyResponses", modifyResponses); 201 attrs.add("modifyDNRequests", modifyDNRequests); 202 attrs.add("modifyDNResponses", modifyDNResponses); 203 attrs.add("searchRequests", searchRequests); 204 attrs.add("searchOneRequests", searchOneRequests); 205 attrs.add("searchSubRequests", searchSubRequests); 206 attrs.add("searchResultEntries", searchResultEntries); 207 attrs.add("searchResultReferences", searchResultReferences); 208 attrs.add("searchResultsDone", searchResultsDone); 209 attrs.add("unbindRequests", unbindRequests); 210 211 // adds 212 attrs.add("ds-mon-add-operations-total-count", addOperationCount); 213 attrs.add("ds-mon-resident-time-add-operations-total-time", addOperationTime); 214 215 // search 216 attrs.add("ds-mon-search-operations-total-count", searchOperationCount); 217 attrs.add("ds-mon-resident-time-search-operations-total-time", searchOperationTime); 218 219 // bind 220 attrs.add("ds-mon-bind-operations-total-count", bindOperationCount); 221 attrs.add("ds-mon-resident-time-bind-operations-total-time", bindOperationTime); 222 223 // unbind 224 attrs.add("ds-mon-unbind-operations-total-count", unbindOperationCount); 225 attrs.add("ds-mon-resident-time-unbind-operations-total-time", unbindOperationTime); 226 227 // compare 228 attrs.add("ds-mon-compare-operations-total-count", compOperationCount); 229 attrs.add("ds-mon-resident-time-compare-operations-total-time", compOperationTime); 230 231 // del 232 attrs.add("ds-mon-delete-operations-total-count", delOperationCount); 233 attrs.add("ds-mon-resident-time-delete-operations-total-time", delOperationTime); 234 235 // mod 236 attrs.add("ds-mon-mod-operations-total-count", modOperationCount); 237 attrs.add("ds-mon-resident-time-mod-operations-total-time", modOperationTime); 238 239 // moddn 240 attrs.add("ds-mon-moddn-operations-total-count", moddnOperationCount); 241 attrs.add("ds-mon-resident-time-moddn-operations-total-time", moddnOperationTime); 242 243 // abandon 244 attrs.add("ds-mon-abandon-operations-total-count", abandonOperationCount); 245 attrs.add("ds-mon-resident-time-abandon-operations-total-time", abandonOperationTime); 246 247 // extended 248 attrs.add("ds-mon-extended-operations-total-count", extOperationCount); 249 attrs.add("ds-mon-resident-time-extended-operations-total-time", extOperationTime); 250 251 return attrs; 252 } 253 254 255 /** 256 * Clears any statistical information collected to this point. 257 */ 258 public void clearStatistics() 259 { 260 abandonRequests.set(0); 261 addRequests.set(0); 262 addResponses.set(0); 263 bindRequests.set(0); 264 bindResponses.set(0); 265 bytesRead.set(0); 266 bytesWritten.set(0); 267 compareRequests.set(0); 268 compareResponses.set(0); 269 connectionsClosed.set(0); 270 connectionsEstablished.set(0); 271 deleteRequests.set(0); 272 deleteResponses.set(0); 273 extendedRequests.set(0); 274 extendedResponses.set(0); 275 messagesRead.set(0); 276 messagesWritten.set(0); 277 modifyRequests.set(0); 278 modifyResponses.set(0); 279 modifyDNRequests.set(0); 280 modifyDNResponses.set(0); 281 operationsAbandoned.set(0); 282 operationsCompleted.set(0); 283 operationsInitiated.set(0); 284 searchRequests.set(0); 285 searchOneRequests.set(0); 286 searchSubRequests.set(0); 287 searchResultEntries.set(0); 288 searchResultReferences.set(0); 289 searchResultsDone.set(0); 290 unbindRequests.set(0); 291 292 addOperationCount.set(0); 293 addOperationTime.set(0); 294 searchOperationCount.set(0); 295 searchOperationTime.set(0); 296 delOperationCount.set(0); 297 delOperationTime.set(0); 298 bindOperationCount.set(0); 299 bindOperationTime.set(0); 300 unbindOperationCount.set(0); 301 unbindOperationTime.set(0); 302 compOperationCount.set(0); 303 compOperationTime.set(0); 304 modOperationCount.set(0); 305 modOperationTime.set(0); 306 moddnOperationCount.set(0); 307 moddnOperationTime.set(0); 308 abandonOperationCount.set(0); 309 abandonOperationTime.set(0); 310 extOperationCount.set(0); 311 extOperationTime.set(0); 312 } 313 314 315 316 317 /** 318 * Updates the appropriate set of counters to indicate that a new 319 * connection has been established. 320 */ 321 public void updateConnect() 322 { 323 connectionsEstablished.getAndIncrement(); 324 } 325 326 327 328 /** 329 * Updates the appropriate set of counters to indicate that a 330 * connection has been closed. 331 */ 332 public void updateDisconnect() 333 { 334 connectionsClosed.getAndIncrement(); 335 } 336 337 338 339 /** 340 * Updates the appropriate set of counters to indicate that the 341 * specified number of bytes have been read by the client. 342 * 343 * @param bytesRead 344 * The number of bytes read by the client. 345 */ 346 public void updateBytesRead(int bytesRead) 347 { 348 this.bytesRead.getAndAdd(bytesRead); 349 } 350 351 352 353 /** 354 * Updates the appropriate set of counters to indicate that the 355 * specified number of bytes have been written to the client. 356 * 357 * @param bytesWritten 358 * The number of bytes written to the client. 359 */ 360 public void updateBytesWritten(int bytesWritten) 361 { 362 this.bytesWritten.getAndAdd(bytesWritten); 363 } 364 365 366 367 /** 368 * Updates the appropriate set of counters based on the provided 369 * message that has been read from the client. 370 * 371 * @param message 372 * The message that was read from the client. 373 */ 374 public void updateMessageRead(LDAPMessage message) 375 { 376 messagesRead.getAndIncrement(); 377 operationsInitiated.getAndIncrement(); 378 379 switch (message.getProtocolOp().getType()) 380 { 381 case OP_TYPE_ABANDON_REQUEST: 382 abandonRequests.getAndIncrement(); 383 break; 384 case OP_TYPE_ADD_REQUEST: 385 addRequests.getAndIncrement(); 386 break; 387 case OP_TYPE_BIND_REQUEST: 388 bindRequests.getAndIncrement(); 389 break; 390 case OP_TYPE_COMPARE_REQUEST: 391 compareRequests.getAndIncrement(); 392 break; 393 case OP_TYPE_DELETE_REQUEST: 394 deleteRequests.getAndIncrement(); 395 break; 396 case OP_TYPE_EXTENDED_REQUEST: 397 extendedRequests.getAndIncrement(); 398 break; 399 case OP_TYPE_MODIFY_REQUEST: 400 modifyRequests.getAndIncrement(); 401 break; 402 case OP_TYPE_MODIFY_DN_REQUEST: 403 modifyDNRequests.getAndIncrement(); 404 break; 405 case OP_TYPE_SEARCH_REQUEST: 406 searchRequests.getAndIncrement(); 407 SearchRequestProtocolOp s = (SearchRequestProtocolOp)message 408 .getProtocolOp(); 409 switch (s.getScope().asEnum()) 410 { 411 case BASE_OBJECT: 412 // we don't count base object searches as 413 // this value can be derived from the others 414 break; 415 case SINGLE_LEVEL: 416 searchOneRequests.getAndIncrement(); 417 break; 418 case WHOLE_SUBTREE: 419 searchSubRequests.getAndIncrement(); 420 break; 421 default: 422 break; 423 } 424 break; 425 case OP_TYPE_UNBIND_REQUEST: 426 unbindRequests.getAndIncrement(); 427 break; 428 } 429 } 430 431 432 433 /** 434 * Updates the appropriate set of counters based on the provided 435 * message that has been written to the client. 436 * 437 * @param message 438 * The message that was written to the client. 439 */ 440 public void updateMessageWritten(LDAPMessage message) 441 { 442 messagesWritten.getAndIncrement(); 443 444 switch (message.getProtocolOp().getType()) 445 { 446 case OP_TYPE_ADD_RESPONSE: 447 addResponses.getAndIncrement(); 448 operationsCompleted.getAndIncrement(); 449 break; 450 case OP_TYPE_BIND_RESPONSE: 451 bindResponses.getAndIncrement(); 452 operationsCompleted.getAndIncrement(); 453 break; 454 case OP_TYPE_COMPARE_RESPONSE: 455 compareResponses.getAndIncrement(); 456 operationsCompleted.getAndIncrement(); 457 break; 458 case OP_TYPE_DELETE_RESPONSE: 459 deleteResponses.getAndIncrement(); 460 operationsCompleted.getAndIncrement(); 461 break; 462 case OP_TYPE_EXTENDED_RESPONSE: 463 extendedResponses.getAndIncrement(); 464 465 // We don't want to include unsolicited notifications as 466 // "completed" operations. 467 if (message.getMessageID() > 0) 468 { 469 operationsCompleted.getAndIncrement(); 470 } 471 break; 472 case OP_TYPE_MODIFY_RESPONSE: 473 modifyResponses.getAndIncrement(); 474 operationsCompleted.getAndIncrement(); 475 break; 476 case OP_TYPE_MODIFY_DN_RESPONSE: 477 modifyDNResponses.getAndIncrement(); 478 operationsCompleted.getAndIncrement(); 479 break; 480 case OP_TYPE_SEARCH_RESULT_ENTRY: 481 searchResultEntries.getAndIncrement(); 482 break; 483 case OP_TYPE_SEARCH_RESULT_REFERENCE: 484 searchResultReferences.getAndIncrement(); 485 break; 486 case OP_TYPE_SEARCH_RESULT_DONE: 487 searchResultsDone.getAndIncrement(); 488 operationsCompleted.getAndIncrement(); 489 break; 490 } 491 } 492 493 494 495 /** 496 * Updates the appropriate set of counters to indicate that an 497 * operation was abandoned without sending a response to the client. 498 */ 499 public void updateAbandonedOperation() 500 { 501 operationsAbandoned.getAndIncrement(); 502 } 503 504 /** 505 * Retrieves the number of client connections that have been 506 * established. 507 * 508 * @return The number of client connections that have been 509 * established. 510 */ 511 public long getConnectionsEstablished() 512 { 513 return connectionsEstablished.get(); 514 } 515 516 517 518 /** 519 * Retrieves the number of client connections that have been closed. 520 * 521 * @return The number of client connections that have been closed. 522 */ 523 public long getConnectionsClosed() 524 { 525 return connectionsClosed.get(); 526 } 527 528 529 530 /** 531 * Retrieves the number of bytes that have been received from clients. 532 * 533 * @return The number of bytes that have been received from clients. 534 */ 535 public long getBytesRead() 536 { 537 return bytesRead.get(); 538 } 539 540 541 542 /** 543 * Retrieves the number of bytes that have been written to clients. 544 * 545 * @return The number of bytes that have been written to clients. 546 */ 547 public long getBytesWritten() 548 { 549 return bytesWritten.get(); 550 } 551 552 553 554 /** 555 * Retrieves the number of LDAP messages that have been received from 556 * clients. 557 * 558 * @return The number of LDAP messages that have been received from 559 * clients. 560 */ 561 public long getMessagesRead() 562 { 563 return messagesRead.get(); 564 } 565 566 567 568 /** 569 * Retrieves the number of LDAP messages that have been written to 570 * clients. 571 * 572 * @return The number of LDAP messages that have been written to 573 * clients. 574 */ 575 public long getMessagesWritten() 576 { 577 return messagesWritten.get(); 578 } 579 580 581 582 /** 583 * Retrieves the number of operations that have been initiated by 584 * clients. 585 * 586 * @return The number of operations that have been initiated by 587 * clients. 588 */ 589 public long getOperationsInitiated() 590 { 591 return operationsInitiated.get(); 592 } 593 594 595 596 /** 597 * Retrieves the number of operations for which the server has 598 * completed processing. 599 * 600 * @return The number of operations for which the server has completed 601 * processing. 602 */ 603 public long getOperationsCompleted() 604 { 605 return operationsCompleted.get(); 606 } 607 608 609 610 /** 611 * Retrieves the number of operations that have been abandoned by 612 * clients. 613 * 614 * @return The number of operations that have been abandoned by 615 * clients. 616 */ 617 public long getOperationsAbandoned() 618 { 619 return operationsAbandoned.get(); 620 } 621 622 623 624 /** 625 * Retrieves the number of abandon requests that have been received. 626 * 627 * @return The number of abandon requests that have been received. 628 */ 629 public long getAbandonRequests() 630 { 631 return abandonRequests.get(); 632 } 633 634 635 636 /** 637 * Retrieves the number of add requests that have been received. 638 * 639 * @return The number of add requests that have been received. 640 */ 641 public long getAddRequests() 642 { 643 return addRequests.get(); 644 } 645 646 647 648 /** 649 * Retrieves the number of add responses that have been sent. 650 * 651 * @return The number of add responses that have been sent. 652 */ 653 public long getAddResponses() 654 { 655 return addResponses.get(); 656 } 657 658 659 660 /** 661 * Retrieves the number of bind requests that have been received. 662 * 663 * @return The number of bind requests that have been received. 664 */ 665 public long getBindRequests() 666 { 667 return bindRequests.get(); 668 } 669 670 671 672 /** 673 * Retrieves the number of bind responses that have been sent. 674 * 675 * @return The number of bind responses that have been sent. 676 */ 677 public long getBindResponses() 678 { 679 return bindResponses.get(); 680 } 681 682 683 684 /** 685 * Retrieves the number of compare requests that have been received. 686 * 687 * @return The number of compare requests that have been received. 688 */ 689 public long getCompareRequests() 690 { 691 return compareRequests.get(); 692 } 693 694 695 696 /** 697 * Retrieves the number of compare responses that have been sent. 698 * 699 * @return The number of compare responses that have been sent. 700 */ 701 public long getCompareResponses() 702 { 703 return compareResponses.get(); 704 } 705 706 707 708 /** 709 * Retrieves the number of delete requests that have been received. 710 * 711 * @return The number of delete requests that have been received. 712 */ 713 public long getDeleteRequests() 714 { 715 return deleteRequests.get(); 716 } 717 718 719 720 /** 721 * Retrieves the number of delete responses that have been sent. 722 * 723 * @return The number of delete responses that have been sent. 724 */ 725 public long getDeleteResponses() 726 { 727 return deleteResponses.get(); 728 } 729 730 731 732 /** 733 * Retrieves the number of extended requests that have been received. 734 * 735 * @return The number of extended requests that have been received. 736 */ 737 public long getExtendedRequests() 738 { 739 return extendedRequests.get(); 740 } 741 742 743 744 /** 745 * Retrieves the number of extended responses that have been sent. 746 * 747 * @return The number of extended responses that have been sent. 748 */ 749 public long getExtendedResponses() 750 { 751 return extendedResponses.get(); 752 } 753 754 755 756 /** 757 * Retrieves the number of modify requests that have been received. 758 * 759 * @return The number of modify requests that have been received. 760 */ 761 public long getModifyRequests() 762 { 763 return modifyRequests.get(); 764 } 765 766 767 768 /** 769 * Retrieves the number of modify responses that have been sent. 770 * 771 * @return The number of modify responses that have been sent. 772 */ 773 public long getModifyResponses() 774 { 775 return modifyResponses.get(); 776 } 777 778 779 780 /** 781 * Retrieves the number of modify DN requests that have been received. 782 * 783 * @return The number of modify DN requests that have been received. 784 */ 785 public long getModifyDNRequests() 786 { 787 return modifyDNRequests.get(); 788 } 789 790 791 792 /** 793 * Retrieves the number of modify DN responses that have been sent. 794 * 795 * @return The number of modify DN responses that have been sent. 796 */ 797 public long getModifyDNResponses() 798 { 799 return modifyDNResponses.get(); 800 } 801 802 803 804 /** 805 * Retrieves the number of search requests that have been received. 806 * 807 * @return The number of search requests that have been received. 808 */ 809 public long getSearchRequests() 810 { 811 return searchRequests.get(); 812 } 813 814 815 816 /** 817 * Retrieves the number of one-level search requests that have been received. 818 * 819 * @return The number of one-level search requests that have been received. 820 */ 821 public long getSearchOneRequests() 822 { 823 return searchOneRequests.get(); 824 } 825 826 827 828 /** 829 * Retrieves the number of subtree search requests that have been received. 830 * 831 * @return The number of subtree search requests that have been received. 832 */ 833 public long getSearchSubRequests() 834 { 835 return searchSubRequests.get(); 836 } 837 838 839 840 /** 841 * Retrieves the number of search result entries that have been sent. 842 * 843 * @return The number of search result entries that have been sent. 844 */ 845 public long getSearchResultEntries() 846 { 847 return searchResultEntries.get(); 848 } 849 850 851 852 /** 853 * Retrieves the number of search result references that have been 854 * sent. 855 * 856 * @return The number of search result references that have been sent. 857 */ 858 public long getSearchResultReferences() 859 { 860 return searchResultReferences.get(); 861 } 862 863 864 865 /** 866 * Retrieves the number of search result done messages that have been 867 * sent. 868 * 869 * @return The number of search result done messages that have been 870 * sent. 871 */ 872 public long getSearchResultsDone() 873 { 874 return searchResultsDone.get(); 875 } 876 877 878 879 /** 880 * Retrieves the number of unbind requests that have been received. 881 * 882 * @return The number of unbind requests that have been received. 883 */ 884 public long getUnbindRequests() 885 { 886 return unbindRequests.get(); 887 } 888 889 /** 890 * Update the operation counters and times depending on the OperationType. 891 * @param type of the operation. 892 * @param time of the operation execution. 893 */ 894 895 public void updateOperationMonitoringData(OperationType type, long time) { 896 if (type.equals(OperationType.ADD)) { 897 addOperationCount.getAndIncrement(); 898 addOperationTime.getAndAdd(time); 899 } 900 else if (type.equals(OperationType.SEARCH)) { 901 searchOperationCount.getAndIncrement(); 902 searchOperationTime.getAndAdd(time); 903 } 904 else if (type.equals(OperationType.ABANDON)) { 905 abandonOperationCount.getAndIncrement(); 906 abandonOperationTime.getAndAdd(time); 907 } 908 else if (type.equals(OperationType.BIND)) { 909 bindOperationCount.getAndIncrement(); 910 bindOperationTime.getAndAdd(time); 911 } 912 else if (type.equals(OperationType.UNBIND)) { 913 unbindOperationCount.getAndIncrement(); 914 unbindOperationTime.getAndAdd(time); 915 } 916 else if (type.equals(OperationType.COMPARE)) { 917 compOperationCount.getAndIncrement(); 918 compOperationTime.getAndAdd(time); 919 } 920 else if (type.equals(OperationType.DELETE)) { 921 delOperationCount.getAndIncrement(); 922 delOperationTime.getAndAdd(time); 923 } 924 else if (type.equals(OperationType.EXTENDED)) { 925 extOperationCount.getAndIncrement(); 926 extOperationTime.getAndAdd(time); 927 } 928 else if (type.equals(OperationType.MODIFY)) { 929 modOperationCount.getAndIncrement(); 930 modOperationTime.getAndAdd(time); 931 } 932 else if (type.equals(OperationType.MODIFY_DN)) { 933 moddnOperationCount.getAndIncrement(); 934 moddnOperationTime.getAndAdd(time); 935 } 936 } 937 938}