36
36
import net .openhft .chronicle .queue .impl .table .ReadonlyTableStore ;
37
37
import net .openhft .chronicle .queue .impl .table .SingleTableBuilder ;
38
38
import net .openhft .chronicle .queue .internal .domestic .QueueOffsetSpec ;
39
- import net .openhft .chronicle .threads .*;
39
+ import net .openhft .chronicle .queue .providers .EnterpriseQueueFactories ;
40
+ import net .openhft .chronicle .threads .MediumEventLoop ;
41
+ import net .openhft .chronicle .threads .Pauser ;
42
+ import net .openhft .chronicle .threads .TimingPauser ;
43
+ import net .openhft .chronicle .threads .YieldingPauser ;
40
44
import net .openhft .chronicle .wire .*;
41
45
import org .jetbrains .annotations .NotNull ;
42
46
import org .jetbrains .annotations .Nullable ;
43
47
44
48
import javax .crypto .spec .SecretKeySpec ;
45
49
import java .io .File ;
46
- import java .lang .reflect .Constructor ;
47
50
import java .nio .file .Path ;
48
51
import java .time .LocalTime ;
49
52
import java .time .ZoneId ;
@@ -64,7 +67,6 @@ public class SingleChronicleQueueBuilder extends SelfDescribingMarshallable impl
64
67
public static final long SMALL_BLOCK_SIZE = OS .isWindows () ? OS .SAFE_PAGE_SIZE : OS .pageSize (); // the smallest safe block size on Windows 8+
65
68
66
69
public static final long DEFAULT_SPARSE_CAPACITY = 512L << 30 ;
67
- private static final Constructor <?> ENTERPRISE_QUEUE_CONSTRUCTOR ;
68
70
private static final WireStoreFactory storeFactory = SingleChronicleQueueBuilder ::createStore ;
69
71
private static final Supplier <TimingPauser > TIMING_PAUSER_SUPPLIER = DefaultPauserSupplier .INSTANCE ;
70
72
@@ -74,15 +76,6 @@ public class SingleChronicleQueueBuilder extends SelfDescribingMarshallable impl
74
76
CLASS_ALIASES .addAlias (SCQRoll .class , "SCQSRoll" );
75
77
CLASS_ALIASES .addAlias (SCQIndexing .class , "SCQSIndexing" );
76
78
CLASS_ALIASES .addAlias (SingleChronicleQueueStore .class , "SCQStore" );
77
-
78
- Constructor <?> co ;
79
- try {
80
- co = ((Class <?>) Class .forName ("software.chronicle.enterprise.queue.EnterpriseSingleChronicleQueue" )).getDeclaredConstructors ()[0 ];
81
- Jvm .setAccessible (co );
82
- } catch (Exception e ) {
83
- co = null ;
84
- }
85
- ENTERPRISE_QUEUE_CONSTRUCTOR = co ;
86
79
}
87
80
88
81
private BufferMode writeBufferMode = BufferMode .None ;
@@ -224,7 +217,7 @@ static SingleChronicleQueueStore createStore(@NotNull RollingChronicleQueue queu
224
217
}
225
218
226
219
public static boolean areEnterpriseFeaturesAvailable () {
227
- return ENTERPRISE_QUEUE_CONSTRUCTOR != null ;
220
+ return EnterpriseQueueFactories . get (). areEnterpriseFeaturesAvailable () ;
228
221
}
229
222
230
223
private static RollCycle loadDefaultRollCycle () {
@@ -284,10 +277,10 @@ public SingleChronicleQueue build() {
284
277
285
278
// It is important to check enterprise features after preBuild()
286
279
// Enterprise-only config options can be loaded from the metadata
287
- if (checkEnterpriseFeaturesRequested ())
288
- chronicleQueue = buildEnterprise ( );
289
- else
290
- chronicleQueue = new SingleChronicleQueue (this );
280
+ if (checkEnterpriseFeaturesRequested () && ! areEnterpriseFeaturesAvailable ()) {
281
+ throw new IllegalStateException ( "Enterprise features requested but Chronicle Queue Enterprise is not in the class path!" );
282
+ }
283
+ chronicleQueue = EnterpriseQueueFactories . get (). newInstance (this );
291
284
292
285
postBuild (chronicleQueue );
293
286
@@ -324,23 +317,11 @@ private boolean checkEnterpriseFeaturesRequested() {
324
317
}
325
318
326
319
public static boolean onlyAvailableInEnterprise (final String feature ) {
327
- if (ENTERPRISE_QUEUE_CONSTRUCTOR == null )
320
+ if (! areEnterpriseFeaturesAvailable () )
328
321
Jvm .warn ().on (SingleChronicleQueueBuilder .class , feature + " is only supported in Chronicle Queue Enterprise. If you would like to use this feature, please contact sales@chronicle.software for more information." );
329
322
return true ;
330
323
}
331
324
332
- @ NotNull
333
- private SingleChronicleQueue buildEnterprise () {
334
- if (ENTERPRISE_QUEUE_CONSTRUCTOR == null )
335
- throw new IllegalStateException ("Enterprise features requested but Chronicle Queue Enterprise is not in the class path!" );
336
-
337
- try {
338
- return (SingleChronicleQueue ) ENTERPRISE_QUEUE_CONSTRUCTOR .newInstance (this );
339
- } catch (Exception e ) {
340
- throw new IllegalStateException ("Couldn't create an instance of Enterprise queue" , e );
341
- }
342
- }
343
-
344
325
public SingleChronicleQueueBuilder aesEncryption (@ Nullable byte [] keyBytes ) {
345
326
if (keyBytes == null ) {
346
327
codingSuppliers (null , null );
0 commit comments