001/* 002 * jPOS Project [http://jpos.org] 003 * Copyright (C) 2000-2026 jPOS Software SRL 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Affero General Public License as 007 * published by the Free Software Foundation, either version 3 of the 008 * License, or (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Affero General Public License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jpos.jfr; 020 021import jdk.jfr.Category; 022import jdk.jfr.Event; 023import jdk.jfr.Name; 024import jdk.jfr.StackTrace; 025 026/** Base Java Flight Recorder event for TransactionManager lifecycle notifications. */ 027@Category("jPOS") 028@Name("jpos.TMEvent") 029@StackTrace() 030public class TMEvent extends Event { 031 /** Transaction or participant name associated with the event. */ 032 @Name("name") 033 protected final String name; 034 035 /** Transaction identifier associated with the event. */ 036 @Name("id") 037 protected final long id; 038 039 /** 040 * Creates a transaction manager JFR event. 041 * 042 * @param name transaction or participant name 043 * @param id transaction identifier 044 */ 045 public TMEvent(String name, long id) { 046 this.name = name; 047 this.id = id; 048 } 049 050 /** JFR event emitted during transaction prepare. */ 051 @Name("jpos.TMPrepare") 052 public static class Prepare extends TMEvent { 053 /** 054 * Creates a prepare event. 055 * 056 * @param name transaction or participant name 057 * @param id transaction identifier 058 */ 059 public Prepare(String name, long id) { 060 super(name, id); 061 } 062 } 063 064 /** JFR event emitted during prepare-for-abort. */ 065 @Name("jpos.TMPrepareForAbort") 066 public static class PrepareForAbort extends TMEvent { 067 /** 068 * Creates a prepare-for-abort event. 069 * 070 * @param name transaction or participant name 071 * @param id transaction identifier 072 */ 073 public PrepareForAbort(String name, long id) { 074 super(name, id); 075 } 076 } 077 078 /** JFR event emitted during commit. */ 079 @Name("jpos.TMCommit") 080 public static class Commit extends TMEvent { 081 /** 082 * Creates a commit event. 083 * 084 * @param name transaction or participant name 085 * @param id transaction identifier 086 */ 087 public Commit(String name, long id) { 088 super(name, id); 089 } 090 } 091 092 /** JFR event emitted during abort. */ 093 @Name("jpos.TMAbort") 094 public static class Abort extends TMEvent { 095 /** 096 * Creates an abort event. 097 * 098 * @param name transaction or participant name 099 * @param id transaction identifier 100 */ 101 public Abort(String name, long id) { 102 super(name, id); 103 } 104 } 105 106 /** JFR event emitted when capturing a transaction snapshot. */ 107 @Name("jpos.TMSnapshot") 108 public static class Snapshot extends TMEvent { 109 /** 110 * Creates a snapshot event. 111 * 112 * @param name transaction or participant name 113 * @param id transaction identifier 114 */ 115 public Snapshot(String name, long id) { 116 super(name, id); 117 } 118 } 119 120 /** JFR event emitted when a transaction is paused. */ 121 @Name("jpos.TMPause") 122 public static class Pause extends TMEvent { 123 /** 124 * Creates a pause event. 125 * 126 * @param name transaction or participant name 127 * @param id transaction identifier 128 */ 129 public Pause(String name, long id) { 130 super(name, id); 131 } 132 } 133 134 /** JFR event emitted during recovery. */ 135 @Name("jpos.TMRecover") 136 public static class Recover extends TMEvent { 137 /** 138 * Creates a recovery event. 139 * 140 * @param name transaction or participant name 141 * @param id transaction identifier 142 */ 143 public Recover(String name, long id) { 144 super(name, id); 145 } 146 } 147}