github.com/cyverse/go-irodsclient@v0.13.2/irods/metrics/metrics.go (about) 1 package metrics 2 3 import "sync" 4 5 // IRODSMetrics - contains IRODS metrics 6 type IRODSMetrics struct { 7 // operations 8 stat uint64 9 list uint64 10 search uint64 11 collectionCreate uint64 12 collectionDelete uint64 13 collectionRename uint64 14 dataObjectCreate uint64 15 dataObjectOpen uint64 16 dataObjectClose uint64 17 dataObjectDelete uint64 18 dataObjectRename uint64 19 dataObjectUpdate uint64 20 dataObjectCopy uint64 21 dataObjectRead uint64 22 dataObjectWrite uint64 23 metadataList uint64 24 metadataCreate uint64 25 metadataDelete uint64 26 metadataUpdate uint64 27 accessList uint64 28 accessUpdate uint64 29 30 // transfer 31 bytesSent uint64 32 bytesReceived uint64 33 34 // cache 35 cacheHit uint64 36 cacheMiss uint64 37 38 // file handles - gauge 39 openFileHandles uint64 40 41 // connections - gauge 42 connectionsOpened uint64 43 connectionsOccupied uint64 44 45 // failures 46 requestResponseFailures uint64 47 connectionFailures uint64 48 connectionPoolFailures uint64 49 50 mutex sync.Mutex 51 } 52 53 // IncreaseCounterForStat increases the counter for dataobject/collection stat 54 func (metrics *IRODSMetrics) IncreaseCounterForStat(n uint64) { 55 metrics.mutex.Lock() 56 defer metrics.mutex.Unlock() 57 58 metrics.stat += n 59 } 60 61 // GetCounterForStat returns the counter for dataobject/collection stat 62 func (metrics *IRODSMetrics) GetCounterForStat() uint64 { 63 metrics.mutex.Lock() 64 defer metrics.mutex.Unlock() 65 66 return metrics.stat 67 } 68 69 // GetAndClearCounterForStat returns the counter for dataobject/collection stat then clear 70 func (metrics *IRODSMetrics) GetAndClearCounterForStat() uint64 { 71 metrics.mutex.Lock() 72 defer metrics.mutex.Unlock() 73 74 stat := metrics.stat 75 metrics.stat = 0 76 return stat 77 } 78 79 // IncreaseCounterForList increases the counter for listing 80 func (metrics *IRODSMetrics) IncreaseCounterForList(n uint64) { 81 metrics.mutex.Lock() 82 defer metrics.mutex.Unlock() 83 84 metrics.list += n 85 } 86 87 // GetCounterForList returns the counter for listing 88 func (metrics *IRODSMetrics) GetCounterForList() uint64 { 89 metrics.mutex.Lock() 90 defer metrics.mutex.Unlock() 91 92 return metrics.list 93 } 94 95 // GetAndClearCounterForList returns the counter for listing then clear 96 func (metrics *IRODSMetrics) GetAndClearCounterForList() uint64 { 97 metrics.mutex.Lock() 98 defer metrics.mutex.Unlock() 99 100 list := metrics.list 101 metrics.list = 0 102 return list 103 } 104 105 // IncreaseCounterForSearch increases the counter for search 106 func (metrics *IRODSMetrics) IncreaseCounterForSearch(n uint64) { 107 metrics.mutex.Lock() 108 defer metrics.mutex.Unlock() 109 110 metrics.search += n 111 } 112 113 // GetCounterForSearch returns the counter for search 114 func (metrics *IRODSMetrics) GetCounterForSearch() uint64 { 115 metrics.mutex.Lock() 116 defer metrics.mutex.Unlock() 117 118 return metrics.search 119 } 120 121 // GetAndClearCounterForSearch returns the counter for search then clear 122 func (metrics *IRODSMetrics) GetAndClearCounterForSearch() uint64 { 123 metrics.mutex.Lock() 124 defer metrics.mutex.Unlock() 125 126 search := metrics.search 127 metrics.search = 0 128 return search 129 } 130 131 // IncreaseCounterForCollectionCreate increases the counter for collection creation 132 func (metrics *IRODSMetrics) IncreaseCounterForCollectionCreate(n uint64) { 133 metrics.mutex.Lock() 134 defer metrics.mutex.Unlock() 135 136 metrics.collectionCreate += n 137 } 138 139 // GetCounterForCollectionCreate returns the counter for collection creation 140 func (metrics *IRODSMetrics) GetCounterForCollectionCreate() uint64 { 141 metrics.mutex.Lock() 142 defer metrics.mutex.Unlock() 143 144 return metrics.collectionCreate 145 } 146 147 // GetAndClearCounterForCollectionCreate returns the counter for collection creation then clear 148 func (metrics *IRODSMetrics) GetAndClearCounterForCollectionCreate() uint64 { 149 metrics.mutex.Lock() 150 defer metrics.mutex.Unlock() 151 152 create := metrics.collectionCreate 153 metrics.collectionCreate = 0 154 return create 155 } 156 157 // IncreaseCounterForCollectionDelete increases the counter for collection deletion 158 func (metrics *IRODSMetrics) IncreaseCounterForCollectionDelete(n uint64) { 159 metrics.mutex.Lock() 160 defer metrics.mutex.Unlock() 161 162 metrics.collectionDelete += n 163 } 164 165 // GetCounterForCollectionDelete returns the counter for collection deletion 166 func (metrics *IRODSMetrics) GetCounterForCollectionDelete() uint64 { 167 metrics.mutex.Lock() 168 defer metrics.mutex.Unlock() 169 170 return metrics.collectionDelete 171 } 172 173 // GetAndClearCounterForCollectionDelete returns the counter for collection deletion then clear 174 func (metrics *IRODSMetrics) GetAndClearCounterForCollectionDelete() uint64 { 175 metrics.mutex.Lock() 176 defer metrics.mutex.Unlock() 177 178 delete := metrics.collectionDelete 179 metrics.collectionDelete = 0 180 return delete 181 } 182 183 // IncreaseCounterForCollectionRename increases the counter for collection renameing 184 func (metrics *IRODSMetrics) IncreaseCounterForCollectionRename(n uint64) { 185 metrics.mutex.Lock() 186 defer metrics.mutex.Unlock() 187 188 metrics.collectionRename += n 189 } 190 191 // GetCounterForCollectionRename returns the counter for collection renameing 192 func (metrics *IRODSMetrics) GetCounterForCollectionRename() uint64 { 193 metrics.mutex.Lock() 194 defer metrics.mutex.Unlock() 195 196 return metrics.collectionRename 197 } 198 199 // GetAndClearCounterForCollectionRename returns the counter for collection renameing then clear 200 func (metrics *IRODSMetrics) GetAndClearCounterForCollectionRename() uint64 { 201 metrics.mutex.Lock() 202 defer metrics.mutex.Unlock() 203 204 rename := metrics.collectionRename 205 metrics.collectionRename = 0 206 return rename 207 } 208 209 // IncreaseCounterForDataObjectCreate increases the counter for data object creation 210 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectCreate(n uint64) { 211 metrics.mutex.Lock() 212 defer metrics.mutex.Unlock() 213 214 metrics.dataObjectCreate += n 215 } 216 217 // GetCounterForDataObjectCreate returns the counter for data object creation 218 func (metrics *IRODSMetrics) GetCounterForDataObjectCreate() uint64 { 219 metrics.mutex.Lock() 220 defer metrics.mutex.Unlock() 221 222 return metrics.dataObjectCreate 223 } 224 225 // GetAndClearCounterForDataObjectCreate returns the counter for data object creation then clear 226 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectCreate() uint64 { 227 metrics.mutex.Lock() 228 defer metrics.mutex.Unlock() 229 230 create := metrics.dataObjectCreate 231 metrics.dataObjectCreate = 0 232 return create 233 } 234 235 // IncreaseCounterForDataObjectOpen increases the counter for data object opening 236 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectOpen(n uint64) { 237 metrics.mutex.Lock() 238 defer metrics.mutex.Unlock() 239 240 metrics.dataObjectOpen += n 241 } 242 243 // GetCounterForDataObjectOpen returns the counter for data object opening 244 func (metrics *IRODSMetrics) GetCounterForDataObjectOpen() uint64 { 245 metrics.mutex.Lock() 246 defer metrics.mutex.Unlock() 247 248 return metrics.dataObjectOpen 249 } 250 251 // GetAndClearCounterForDataObjectOpen returns the counter for data object opening then clear 252 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectOpen() uint64 { 253 metrics.mutex.Lock() 254 defer metrics.mutex.Unlock() 255 256 open := metrics.dataObjectOpen 257 metrics.dataObjectOpen = 0 258 return open 259 } 260 261 // IncreaseCounterForDataObjectClose increases the counter for data object closing 262 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectClose(n uint64) { 263 metrics.mutex.Lock() 264 defer metrics.mutex.Unlock() 265 266 metrics.dataObjectClose += n 267 } 268 269 // GetCounterForDataObjectClose returns the counter for data object closing 270 func (metrics *IRODSMetrics) GetCounterForDataObjectClose() uint64 { 271 metrics.mutex.Lock() 272 defer metrics.mutex.Unlock() 273 274 return metrics.dataObjectClose 275 } 276 277 // GetAndClearCounterForDataObjectClose returns the counter for data object closing then clear 278 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectClose() uint64 { 279 metrics.mutex.Lock() 280 defer metrics.mutex.Unlock() 281 282 close := metrics.dataObjectClose 283 metrics.dataObjectClose = 0 284 return close 285 } 286 287 // IncreaseCounterForDataObjectDelete increases the counter for data object deletion 288 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectDelete(n uint64) { 289 metrics.mutex.Lock() 290 defer metrics.mutex.Unlock() 291 292 metrics.dataObjectDelete += n 293 } 294 295 // GetCounterForDataObjectDelete returns the counter for data object deletion 296 func (metrics *IRODSMetrics) GetCounterForDataObjectDelete() uint64 { 297 metrics.mutex.Lock() 298 defer metrics.mutex.Unlock() 299 300 return metrics.dataObjectDelete 301 } 302 303 // GetAndClearCounterForDataObjectDelete returns the counter for data object deletion then clear 304 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectDelete() uint64 { 305 metrics.mutex.Lock() 306 defer metrics.mutex.Unlock() 307 308 delete := metrics.dataObjectDelete 309 metrics.dataObjectDelete = 0 310 return delete 311 } 312 313 // IncreaseCounterForDataObjectRename increases the counter for data object renaming 314 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectRename(n uint64) { 315 metrics.mutex.Lock() 316 defer metrics.mutex.Unlock() 317 318 metrics.dataObjectRename += n 319 } 320 321 // GetCounterForDataObjectRename returns the counter for data object renaming 322 func (metrics *IRODSMetrics) GetCounterForDataObjectRename() uint64 { 323 metrics.mutex.Lock() 324 defer metrics.mutex.Unlock() 325 326 return metrics.dataObjectRename 327 } 328 329 // GetAndClearCounterForDataObjectRename returns the counter for data object renaming then clear 330 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectRename() uint64 { 331 metrics.mutex.Lock() 332 defer metrics.mutex.Unlock() 333 334 rename := metrics.dataObjectRename 335 metrics.dataObjectRename = 0 336 return rename 337 } 338 339 // IncreaseCounterForDataObjectCopy increases the counter for data object copy 340 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectCopy(n uint64) { 341 metrics.mutex.Lock() 342 defer metrics.mutex.Unlock() 343 344 metrics.dataObjectCopy += n 345 } 346 347 // GetCounterForDataObjectCopy returns the counter for data object copy 348 func (metrics *IRODSMetrics) GetCounterForDataObjectCopy() uint64 { 349 metrics.mutex.Lock() 350 defer metrics.mutex.Unlock() 351 352 return metrics.dataObjectCopy 353 } 354 355 // GetAndClearCounterForDataObjectCopy returns the counter for data object copy then clear 356 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectCopy() uint64 { 357 metrics.mutex.Lock() 358 defer metrics.mutex.Unlock() 359 360 copy := metrics.dataObjectCopy 361 metrics.dataObjectCopy = 0 362 return copy 363 } 364 365 // IncreaseCounterForDataObjectUpdate increases the counter for data object update (truncate, ETC) 366 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectUpdate(n uint64) { 367 metrics.mutex.Lock() 368 defer metrics.mutex.Unlock() 369 370 metrics.dataObjectUpdate += n 371 } 372 373 // GetCounterForDataObjectUpdate returns the counter for data object update (truncate, ETC) 374 func (metrics *IRODSMetrics) GetCounterForDataObjectUpdate() uint64 { 375 metrics.mutex.Lock() 376 defer metrics.mutex.Unlock() 377 378 return metrics.dataObjectUpdate 379 } 380 381 // GetAndClearCounterForDataObjectUpdate returns the counter for data object update (truncate, ETC) then clear 382 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectUpdate() uint64 { 383 metrics.mutex.Lock() 384 defer metrics.mutex.Unlock() 385 386 update := metrics.dataObjectUpdate 387 metrics.dataObjectUpdate = 0 388 return update 389 } 390 391 // IncreaseCounterForDataObjectRead increases the counter for data object read 392 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectRead(n uint64) { 393 metrics.mutex.Lock() 394 defer metrics.mutex.Unlock() 395 396 metrics.dataObjectRead += n 397 } 398 399 // GetCounterForDataObjectRead returns the counter for data object read 400 func (metrics *IRODSMetrics) GetCounterForDataObjectRead() uint64 { 401 metrics.mutex.Lock() 402 defer metrics.mutex.Unlock() 403 404 return metrics.dataObjectRead 405 } 406 407 // GetAndClearCounterForDataObjectRead returns the counter for data object read then clear 408 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectRead() uint64 { 409 metrics.mutex.Lock() 410 defer metrics.mutex.Unlock() 411 412 read := metrics.dataObjectRead 413 metrics.dataObjectRead = 0 414 return read 415 } 416 417 // IncreaseCounterForDataObjectWrite increases the counter for data object write 418 func (metrics *IRODSMetrics) IncreaseCounterForDataObjectWrite(n uint64) { 419 metrics.mutex.Lock() 420 defer metrics.mutex.Unlock() 421 422 metrics.dataObjectWrite += n 423 } 424 425 // GetCounterForDataObjectWrite returns the counter for data object write 426 func (metrics *IRODSMetrics) GetCounterForDataObjectWrite() uint64 { 427 metrics.mutex.Lock() 428 defer metrics.mutex.Unlock() 429 430 return metrics.dataObjectWrite 431 } 432 433 // GetAndClearCounterForDataObjectWrite returns the counter for data object write then clear 434 func (metrics *IRODSMetrics) GetAndClearCounterForDataObjectWrite() uint64 { 435 metrics.mutex.Lock() 436 defer metrics.mutex.Unlock() 437 438 write := metrics.dataObjectWrite 439 metrics.dataObjectWrite = 0 440 return write 441 } 442 443 // IncreaseCounterForMetadataList increases the counter for metadata listing 444 func (metrics *IRODSMetrics) IncreaseCounterForMetadataList(n uint64) { 445 metrics.mutex.Lock() 446 defer metrics.mutex.Unlock() 447 448 metrics.metadataList += n 449 } 450 451 // GetCounterForMetadataList returns the counter for metadata listing 452 func (metrics *IRODSMetrics) GetCounterForMetadataList() uint64 { 453 metrics.mutex.Lock() 454 defer metrics.mutex.Unlock() 455 456 return metrics.metadataList 457 } 458 459 // GetAndClearCounterForMetadataList returns the counter for metadata listing then clear 460 func (metrics *IRODSMetrics) GetAndClearCounterForMetadataList() uint64 { 461 metrics.mutex.Lock() 462 defer metrics.mutex.Unlock() 463 464 list := metrics.metadataList 465 metrics.metadataList = 0 466 return list 467 } 468 469 // IncreaseCounterForMetadataCreate increases the counter for metadata creatation 470 func (metrics *IRODSMetrics) IncreaseCounterForMetadataCreate(n uint64) { 471 metrics.mutex.Lock() 472 defer metrics.mutex.Unlock() 473 474 metrics.metadataCreate += n 475 } 476 477 // GetCounterForMetadataCreate returns the counter for metadata creatation 478 func (metrics *IRODSMetrics) GetCounterForMetadataCreate() uint64 { 479 metrics.mutex.Lock() 480 defer metrics.mutex.Unlock() 481 482 return metrics.metadataCreate 483 } 484 485 // GetAndClearCounterForMetadataCreate returns the counter for metadata creatation then clear 486 func (metrics *IRODSMetrics) GetAndClearCounterForMetadataCreate() uint64 { 487 metrics.mutex.Lock() 488 defer metrics.mutex.Unlock() 489 490 create := metrics.metadataCreate 491 metrics.metadataCreate = 0 492 return create 493 } 494 495 // IncreaseCounterForMetadataDelete increases the counter for metadata deletion 496 func (metrics *IRODSMetrics) IncreaseCounterForMetadataDelete(n uint64) { 497 metrics.mutex.Lock() 498 defer metrics.mutex.Unlock() 499 500 metrics.metadataDelete += n 501 } 502 503 // GetCounterForMetadataDelete returns the counter for metadata deletion 504 func (metrics *IRODSMetrics) GetCounterForMetadataDelete() uint64 { 505 metrics.mutex.Lock() 506 defer metrics.mutex.Unlock() 507 508 return metrics.metadataDelete 509 } 510 511 // GetAndClearCounterForMetadataDelete returns the counter for metadata deletion then clear 512 func (metrics *IRODSMetrics) GetAndClearCounterForMetadataDelete() uint64 { 513 metrics.mutex.Lock() 514 defer metrics.mutex.Unlock() 515 516 delete := metrics.metadataDelete 517 metrics.metadataDelete = 0 518 return delete 519 } 520 521 // IncreaseCounterForMetadataUpdate increases the counter for metadata update 522 func (metrics *IRODSMetrics) IncreaseCounterForMetadataUpdate(n uint64) { 523 metrics.mutex.Lock() 524 defer metrics.mutex.Unlock() 525 526 metrics.metadataUpdate += n 527 } 528 529 // GetCounterForMetadataUpdate returns the counter for metadata update 530 func (metrics *IRODSMetrics) GetCounterForMetadataUpdate() uint64 { 531 metrics.mutex.Lock() 532 defer metrics.mutex.Unlock() 533 534 return metrics.metadataUpdate 535 } 536 537 // GetAndClearCounterForMetadataUpdate returns the counter for metadata update then clear 538 func (metrics *IRODSMetrics) GetAndClearCounterForMetadataUpdate() uint64 { 539 metrics.mutex.Lock() 540 defer metrics.mutex.Unlock() 541 542 update := metrics.metadataUpdate 543 metrics.metadataUpdate = 0 544 return update 545 } 546 547 // IncreaseCounterForAccessList increases the counter for dataobject/collection access listing 548 func (metrics *IRODSMetrics) IncreaseCounterForAccessList(n uint64) { 549 metrics.mutex.Lock() 550 defer metrics.mutex.Unlock() 551 552 metrics.accessList += n 553 } 554 555 // GetCounterForAccessList returns the counter for dataobject/collection access listing 556 func (metrics *IRODSMetrics) GetCounterForAccessList() uint64 { 557 metrics.mutex.Lock() 558 defer metrics.mutex.Unlock() 559 560 return metrics.accessList 561 } 562 563 // GetAndClearCounterForAccessList returns the counter for dataobject/collection access listing then clear 564 func (metrics *IRODSMetrics) GetAndClearCounterForAccessList() uint64 { 565 metrics.mutex.Lock() 566 defer metrics.mutex.Unlock() 567 568 list := metrics.accessList 569 metrics.accessList = 0 570 return list 571 } 572 573 // IncreaseCounterForAccessUpdate increases the counter for dataobject/collection access update 574 func (metrics *IRODSMetrics) IncreaseCounterForAccessUpdate(n uint64) { 575 metrics.mutex.Lock() 576 defer metrics.mutex.Unlock() 577 578 metrics.accessUpdate += n 579 } 580 581 // GetCounterForAccessUpdate returns the counter for dataobject/collection access update 582 func (metrics *IRODSMetrics) GetCounterForAccessUpdate() uint64 { 583 metrics.mutex.Lock() 584 defer metrics.mutex.Unlock() 585 586 return metrics.accessUpdate 587 } 588 589 // GetAndClearCounterForAccessUpdate returns the counter for dataobject/collection access update then clear 590 func (metrics *IRODSMetrics) GetAndClearCounterForAccessUpdate() uint64 { 591 metrics.mutex.Lock() 592 defer metrics.mutex.Unlock() 593 594 update := metrics.accessUpdate 595 metrics.accessUpdate = 0 596 return update 597 } 598 599 // IncreaseBytesSent increases bytes sent 600 func (metrics *IRODSMetrics) IncreaseBytesSent(n uint64) { 601 metrics.mutex.Lock() 602 defer metrics.mutex.Unlock() 603 604 metrics.bytesSent += n 605 } 606 607 // GetBytesSent returns bytes sent 608 func (metrics *IRODSMetrics) GetBytesSent() uint64 { 609 metrics.mutex.Lock() 610 defer metrics.mutex.Unlock() 611 612 return metrics.bytesSent 613 } 614 615 // GetAndClearBytesSent returns bytes sent then clear 616 func (metrics *IRODSMetrics) GetAndClearBytesSent() uint64 { 617 metrics.mutex.Lock() 618 defer metrics.mutex.Unlock() 619 620 sent := metrics.bytesSent 621 metrics.bytesSent = 0 622 return sent 623 } 624 625 // IncreaseBytesReceived increases bytes received 626 func (metrics *IRODSMetrics) IncreaseBytesReceived(n uint64) { 627 metrics.mutex.Lock() 628 defer metrics.mutex.Unlock() 629 630 metrics.bytesReceived += n 631 } 632 633 // GetBytesReceived returns bytes received 634 func (metrics *IRODSMetrics) GetBytesReceived() uint64 { 635 metrics.mutex.Lock() 636 defer metrics.mutex.Unlock() 637 638 return metrics.bytesReceived 639 } 640 641 // GetAndClearBytesReceived returns bytes received then clear 642 func (metrics *IRODSMetrics) GetAndClearBytesReceived() uint64 { 643 metrics.mutex.Lock() 644 defer metrics.mutex.Unlock() 645 646 received := metrics.bytesReceived 647 metrics.bytesReceived = 0 648 return received 649 } 650 651 // IncreaseCounterForCacheHit increases the counter for cache hit 652 func (metrics *IRODSMetrics) IncreaseCounterForCacheHit(n uint64) { 653 metrics.mutex.Lock() 654 defer metrics.mutex.Unlock() 655 656 metrics.cacheHit += n 657 } 658 659 // GetCounterForCacheHit returns the counter for cache hit 660 func (metrics *IRODSMetrics) GetCounterForCacheHit() uint64 { 661 metrics.mutex.Lock() 662 defer metrics.mutex.Unlock() 663 664 return metrics.cacheHit 665 } 666 667 // GetAndClearCounterForCacheHit returns the counter for cache hit then clear 668 func (metrics *IRODSMetrics) GetAndClearCounterForCacheHit() uint64 { 669 metrics.mutex.Lock() 670 defer metrics.mutex.Unlock() 671 672 hit := metrics.cacheHit 673 metrics.cacheHit = 0 674 return hit 675 } 676 677 // IncreaseCounterForCacheMiss increases the counter for cache miss 678 func (metrics *IRODSMetrics) IncreaseCounterForCacheMiss(n uint64) { 679 metrics.mutex.Lock() 680 defer metrics.mutex.Unlock() 681 682 metrics.cacheMiss += n 683 } 684 685 // GetCounterForCacheMiss returns the counter for cache miss 686 func (metrics *IRODSMetrics) GetCounterForCacheMiss() uint64 { 687 metrics.mutex.Lock() 688 defer metrics.mutex.Unlock() 689 690 return metrics.cacheMiss 691 } 692 693 // GetAndClearCounterForCacheMiss returns the counter for cache miss then clear 694 func (metrics *IRODSMetrics) GetAndClearCounterForCacheMiss() uint64 { 695 metrics.mutex.Lock() 696 defer metrics.mutex.Unlock() 697 698 miss := metrics.cacheMiss 699 metrics.cacheMiss = 0 700 return miss 701 } 702 703 // IncreaseOpenFileHandles increases the counter for open file handles 704 func (metrics *IRODSMetrics) IncreaseCounterForOpenFileHandles(n uint64) { 705 metrics.mutex.Lock() 706 defer metrics.mutex.Unlock() 707 708 metrics.openFileHandles += n 709 } 710 711 // DecreaseOpenFileHandles decreases the counter for open file handles 712 func (metrics *IRODSMetrics) DecreaseCounterForOpenFileHandles(n uint64) { 713 metrics.mutex.Lock() 714 defer metrics.mutex.Unlock() 715 716 if metrics.openFileHandles < n { 717 metrics.openFileHandles = 0 718 } else { 719 metrics.openFileHandles -= n 720 } 721 } 722 723 // GetCounterForOpenFileHandles returns the counter for open file handles 724 func (metrics *IRODSMetrics) GetCounterForOpenFileHandles() uint64 { 725 metrics.mutex.Lock() 726 defer metrics.mutex.Unlock() 727 728 return metrics.openFileHandles 729 } 730 731 // IncreaseConnectionsOpened increases connections opened 732 func (metrics *IRODSMetrics) IncreaseConnectionsOpened(n uint64) { 733 metrics.mutex.Lock() 734 defer metrics.mutex.Unlock() 735 736 metrics.connectionsOpened += n 737 } 738 739 // DecreaseConnectionsOpened decreases connections opened 740 func (metrics *IRODSMetrics) DecreaseConnectionsOpened(n uint64) { 741 metrics.mutex.Lock() 742 defer metrics.mutex.Unlock() 743 744 if metrics.connectionsOpened < n { 745 metrics.connectionsOpened = 0 746 } else { 747 metrics.connectionsOpened -= n 748 } 749 } 750 751 // GetConnectionsOpened returns connections opened 752 func (metrics *IRODSMetrics) GetConnectionsOpened() uint64 { 753 metrics.mutex.Lock() 754 defer metrics.mutex.Unlock() 755 756 return metrics.connectionsOpened 757 } 758 759 // IncreaseConnectionsOccupied increases connections occupied 760 func (metrics *IRODSMetrics) IncreaseConnectionsOccupied(n uint64) { 761 metrics.mutex.Lock() 762 defer metrics.mutex.Unlock() 763 764 metrics.connectionsOccupied += n 765 } 766 767 // DecreaseConnectionsOccupied decreases connections occupied 768 func (metrics *IRODSMetrics) DecreaseConnectionsOccupied(n uint64) { 769 metrics.mutex.Lock() 770 defer metrics.mutex.Unlock() 771 772 if metrics.connectionsOccupied < n { 773 metrics.connectionsOccupied = 0 774 } else { 775 metrics.connectionsOccupied -= n 776 } 777 } 778 779 // GetConnectionsOccupied returns connections occupied 780 func (metrics *IRODSMetrics) GetConnectionsOccupied() uint64 { 781 metrics.mutex.Lock() 782 defer metrics.mutex.Unlock() 783 784 return metrics.connectionsOccupied 785 } 786 787 func (metrics *IRODSMetrics) ClearConnections() { 788 metrics.mutex.Lock() 789 defer metrics.mutex.Unlock() 790 791 metrics.connectionsOccupied = 0 792 metrics.connectionsOpened = 0 793 } 794 795 // IncreaseCounterForRequestResponseFailures increases the counter for request-response failures 796 func (metrics *IRODSMetrics) IncreaseCounterForRequestResponseFailures(n uint64) { 797 metrics.mutex.Lock() 798 defer metrics.mutex.Unlock() 799 800 metrics.requestResponseFailures += n 801 } 802 803 // GetCounterForRequestResponseFailures returns the counter for request-response failures 804 func (metrics *IRODSMetrics) GetCounterForRequestResponseFailures() uint64 { 805 metrics.mutex.Lock() 806 defer metrics.mutex.Unlock() 807 808 return metrics.requestResponseFailures 809 } 810 811 // GetAndClearCounterForRequestResponseFailures returns the counter for request-response failures then clear 812 func (metrics *IRODSMetrics) GetAndClearCounterForRequestResponseFailures() uint64 { 813 metrics.mutex.Lock() 814 defer metrics.mutex.Unlock() 815 816 failures := metrics.requestResponseFailures 817 metrics.requestResponseFailures = 0 818 return failures 819 } 820 821 // IncreaseCounterForConnectionFailures increases the counter for connection failures 822 func (metrics *IRODSMetrics) IncreaseCounterForConnectionFailures(n uint64) { 823 metrics.mutex.Lock() 824 defer metrics.mutex.Unlock() 825 826 metrics.connectionFailures += n 827 } 828 829 // GetCounterForConnectionFailures returns the counter for connection failures 830 func (metrics *IRODSMetrics) GetCounterForConnectionFailures() uint64 { 831 metrics.mutex.Lock() 832 defer metrics.mutex.Unlock() 833 834 return metrics.connectionFailures 835 } 836 837 // GetAndClearCounterForConnectionFailures returns the counter for connection failures then clear 838 func (metrics *IRODSMetrics) GetAndClearCounterForConnectionFailures() uint64 { 839 metrics.mutex.Lock() 840 defer metrics.mutex.Unlock() 841 842 failures := metrics.connectionFailures 843 metrics.connectionFailures = 0 844 return failures 845 } 846 847 // IncreaseCounterForConnectionPoolFailures increases the counter for connection pool failures 848 func (metrics *IRODSMetrics) IncreaseCounterForConnectionPoolFailures(n uint64) { 849 metrics.mutex.Lock() 850 defer metrics.mutex.Unlock() 851 852 metrics.connectionPoolFailures += n 853 } 854 855 // GetCounterForConnectionPoolFailures returns the counter for connection pool failures 856 func (metrics *IRODSMetrics) GetCounterForConnectionPoolFailures() uint64 { 857 metrics.mutex.Lock() 858 defer metrics.mutex.Unlock() 859 860 return metrics.connectionPoolFailures 861 } 862 863 // GetAndClearCounterForConnectionPoolFailures returns the counter for connection pool failures then clear 864 func (metrics *IRODSMetrics) GetAndClearCounterForConnectionPoolFailures() uint64 { 865 metrics.mutex.Lock() 866 defer metrics.mutex.Unlock() 867 868 failures := metrics.connectionPoolFailures 869 metrics.connectionPoolFailures = 0 870 return failures 871 } 872 873 func (metrics *IRODSMetrics) Sum(other *IRODSMetrics) { 874 metrics.stat += other.stat 875 metrics.list += other.list 876 metrics.search += other.search 877 metrics.collectionCreate += other.collectionCreate 878 metrics.collectionDelete += other.collectionDelete 879 metrics.collectionRename += other.collectionRename 880 metrics.dataObjectCreate += other.dataObjectCreate 881 metrics.dataObjectOpen += other.dataObjectOpen 882 metrics.dataObjectClose += other.dataObjectClose 883 metrics.dataObjectDelete += other.dataObjectDelete 884 metrics.dataObjectRename += other.dataObjectRename 885 metrics.dataObjectUpdate += other.dataObjectUpdate 886 metrics.dataObjectCopy += other.dataObjectCopy 887 metrics.dataObjectRead += other.dataObjectRead 888 metrics.dataObjectWrite += other.dataObjectWrite 889 metrics.metadataList += other.metadataList 890 metrics.metadataCreate += other.metadataCreate 891 metrics.metadataDelete += other.metadataDelete 892 metrics.metadataUpdate += other.metadataUpdate 893 metrics.accessList += other.accessList 894 metrics.accessUpdate += other.accessUpdate 895 metrics.bytesSent += other.bytesSent 896 metrics.bytesReceived += other.bytesReceived 897 metrics.cacheHit += other.cacheHit 898 metrics.cacheMiss += other.cacheMiss 899 metrics.openFileHandles += other.openFileHandles 900 metrics.connectionsOpened += other.connectionsOpened 901 metrics.connectionsOccupied += other.connectionsOccupied 902 metrics.requestResponseFailures += other.requestResponseFailures 903 metrics.connectionFailures += other.connectionFailures 904 metrics.connectionPoolFailures += other.connectionPoolFailures 905 }