-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClAmsMgmtExampleMain.java
More file actions
1415 lines (1271 loc) · 58.1 KB
/
ClAmsMgmtExampleMain.java
File metadata and controls
1415 lines (1271 loc) · 58.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import saAmf.SaAmfLibrary;
import saAmf.SaAmfLibrary.*;
//import saAmf.SaAmfLibrary.SaAmfHAStateT.*;
import saAmf.SaAmfCallbacksT;
import saAmf.SaAmfCallbacksT.*;
import saAmf.SaAmfCSIDescriptorT;
import saAis.SaAisLibrary;
import saAis.SaAisLibrary.*;
import clEoLib.ClEoLibrary;
import clEoLib.ClEoLibrary.*;
import clUtils.*;
import clUtils.ClUtilsLibrary;
import clUtils.ClUtilsLibrary.*;
//import clUtils.ClUtilsLibrary.ClLogSeverityT.*;
import clAmsMgmtClientApi.ClAmsMgmtLibrary;
import clAmsMgmtClientApi.ClAmsMgmtLibrary.*;
import clAmsMgmtClientApi.ClAmsEntityT;
import libc.LibC;
import libc.LibC.*;
import libc.Errno;
import libc.Errno.*;
import java.lang.ProcessHandle;
import java.nio.charset.StandardCharsets;
import java.util.function.BooleanSupplier;
import java.util.function.IntFunction;
import java.util.function.IntSupplier;
import java.util.Arrays;
public class ClAmsMgmtExampleMain {
private static interface CompCfgLibrary extends Library {
public static final String JNA_LIBRARY_NAME = "clCompCfg";
public static final CompCfgLibrary INSTANCE = Native.load(JNA_LIBRARY_NAME, CompCfgLibrary.class);
};
private static long mypid = 0;
private static saAis.SaAisLibrary.SaNameT.ByReference appName = new saAis.SaAisLibrary.SaNameT.ByReference();
private static short svcId = 10;
private static CompCfgLibrary compCfgLib = CompCfgLibrary.INSTANCE;
private static NativeLibrary mwNativeLib = clUtils.ClUtilsLibrary.MW_NATIVE_LIB;
private static clUtils.ClUtilsLibrary utilsLib = clUtils.ClUtilsLibrary.UTILS_INSTANCE;
private static NativeLibrary iocLib = NativeLibrary.getInstance("ClIoc");
private static ClAmsMgmtLibrary amsMgmtLib = ClAmsMgmtLibrary.INSTANCE;
private static final String WORKER0 = "WorkerI0";
private static final String WORKER1 = "WorkerI1";
private static final String NEW_COMP_PREFIX = "dynamicComp";
private static final String BASE_NAME = "dynamicTwoN";
private static void clprintf(int severity, String fmtString, Object...varArgs) {
StackTraceElement e = Thread.currentThread().getStackTrace()[2];
Pointer symPtr = mwNativeLib.getGlobalVariableAddress("CL_LOG_HANDLE_APP");
long handleApp = symPtr.getLong(0);
utilsLib.clLogMsgWrite( handleApp,
severity,
svcId,
"---",
"---",
e.getFileName(),
e.getLineNumber(),
fmtString,
varArgs);
}
private static saAmf.SaAmfLibrary saAmfLib = SaAmfLibrary.INSTANCE;
private static clEoLib.ClEoLibrary eoLib = clEoLib.ClEoLibrary.INSTANCE;
private static LongByReference amfHandle = new LongByReference();
private static saAmf.SaAmfCallbacksT.ByReference callbacks = new saAmf.SaAmfCallbacksT.ByReference();
private static boolean unblockNow = false;
private static saAmf.SaAmfLibrary.SaAmfCSISetCallbackT csiSetCb = (invocation, compName, haState, csiDescriptor) -> {
/*
* Take appropriate action based on state
*/
try {
csiDescriptor.read();
compName.read();
csiDescriptor.csiName.read();
String msg = String.format("Component [%s] : PID [%d]. CSI Set Received\n", Native.toString(compName.value), mypid);
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, msg);
csiDescriptor.csiStateDescriptor.setType(
(haState == saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_ACTIVE)
? saAmf.SaAmfCSIActiveDescriptorT.class
: saAmf.SaAmfCSIStandbyDescriptorT.class
);
csiDescriptor.csiStateDescriptor.read();
clCompAppAMFPrintCSI(csiDescriptor, haState);
switch ( haState ) {
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_ACTIVE:
{
/*
* AMF has requested application to take the active HA state
* for the CSI.
*/
clDhaDemoCreateStart();
saAmfLib.saAmfResponse(amfHandle.getValue(), invocation, saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK);
break;
}
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_STANDBY:
{
/*
* AMF has requested application to take the standby HA state
* for this CSI.
*/
saAmfLib.saAmfResponse(amfHandle.getValue(), invocation, saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK);
break;
}
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_QUIESCED:
{
/*
* AMF has requested application to quiesce the CSI currently
* assigned the active or quiescing HA state. The application
* must stop work associated with the CSI immediately.
*/
clDhaDemoDeleteStart();
saAmfLib.saAmfResponse(amfHandle.getValue(), invocation, saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK);
break;
}
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_QUIESCING:
{
/*
* AMF has requested application to quiesce the CSI currently
* assigned the active HA state. The application must stop work
* associated with the CSI gracefully and not accept any new
* workloads while the work is being terminated.
*/
clDhaDemoDeleteStart();
saAmfLib.saAmfCSIQuiescingComplete(amfHandle.getValue(), invocation, saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK);
break;
}
default:
{
assert false : "Invalid haState";
break;
}
}
}catch (Throwable t) {
t.printStackTrace(); // don't let exceptions escape native callback
}
return;
};
private static saAmf.SaAmfLibrary.SaAmfCSIRemoveCallbackT csiRemoveCb = (invocation, compName, csiName, csiFlags) -> {
try {
compName.read();
csiName.read();
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Component [%s] : PID [%d]. CSI Remove Received\n", Native.toString(compName.value), mypid));
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format(" CSI : %s\n", Native.toString(csiName.value)));
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format(" CSI Flags : 0x%d\n", csiFlags));
/*
* Add application specific logic for removing the work for this CSI.
*/
saAmfLib.saAmfResponse(amfHandle.getValue(), invocation, saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK);
}catch (Throwable t) {
t.printStackTrace(); // avoid letting exceptions escape native callback
}
return;
};
private static saAmf.SaAmfLibrary.SaAmfComponentTerminateCallbackT termCb = (invocation, compName) -> {
try {
int rc = saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK;
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Component [%s] : PID [%d]. Terminating\n", Native.toString(compName.value), mypid));
/*
* Unregister with AMF and respond to AMF saying whether the
* termination was successful or not.
*/
compName.read();
rc = saAmfLib.saAmfComponentUnregister(amfHandle.getValue(), compName.getPointer(), null);
if (rc == saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK) {
saAmfLib.saAmfResponse(amfHandle.getValue(), invocation, saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK);
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Component [%s] : PID [%d]. Terminated\n", Native.toString(compName.value), mypid));
unblockNow = true;
}
else {
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_ERROR, String.format("Component [%s] : PID [%d]. Termination error [0x%x]\n", Native.toString(compName.value), mypid, rc));
}
}catch (Throwable t) {
t.printStackTrace();
}
return;
};
private static void errorexit(int rc, int status) {
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_ERROR, String.format("Component [%s] : PID [%d]. Initialization error [0x%x]\n", Native.toString(appName.value), mypid, rc));
System.exit(status);
}
public static void main(String argv[]) {
mypid = ProcessHandle.current().pid();
saAis.SaAisLibrary.SaVersionT.ByReference version = new saAis.SaAisLibrary.SaVersionT.ByReference();
version.releaseCode = 'B';
version.majorVersion = 01;
version.minorVersion = 01;
version.write();
callbacks.saAmfHealthcheckCallback = null;
callbacks.saAmfComponentTerminateCallback = termCb;
callbacks.saAmfCSISetCallback = csiSetCb;
callbacks.saAmfCSIRemoveCallback = csiRemoveCb;
callbacks.saAmfProtectionGroupTrackCallback = null;
callbacks.saAmfProxiedComponentInstantiateCallback = null;
callbacks.saAmfProxiedComponentCleanupCallback = null;
callbacks.write(); // sync struct
int rc = saAmfLib.saAmfInitialize(amfHandle, callbacks, version);
if (rc != saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK) {
errorexit(rc,-1);
}
FDSet readfds = new FDSet();
readfds.FD_ZERO();
LongByReference dispatch_fd = new LongByReference();
rc = saAmfLib.saAmfSelectionObjectGet(amfHandle.getValue(), dispatch_fd);
if (rc != saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK) {
errorexit(rc,-1);
}
readfds.FD_SET(dispatch_fd.getValue());
/*
* Do the application specific initialization here.
*/
rc = saAmfLib.saAmfComponentNameGet(amfHandle.getValue(), appName);
if (rc != saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK) {
errorexit(rc,-1);
}
appName.read();
rc = saAmfLib.saAmfComponentRegister(amfHandle.getValue(), appName.getPointer(), null);
if (rc != saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK) {
errorexit(rc,-1);
}
/*
* Print out standard information for this component.
*/
IntByReference iocPort = new IntByReference();
eoLib.clEoMyEoIocPortGet(iocPort);
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Component [%s] : PID [%d]. Initializing\n", Native.toString(appName.value), mypid));
Function iocLocalAddrGetFunc = iocLib.getFunction("clIocLocalAddressGet");
int myIocAddr = iocLocalAddrGetFunc.invokeInt(new Object[]{});
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format(" IOC Address : 0x%x\n", myIocAddr));
clprintf(clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format(" IOC Port : 0x%x\n",iocPort.getValue()));
/*
* Block on AMF dispatch file descriptor for callbacks
*/
do {
int err = libc.LibC.INSTANCE.select(dispatch_fd.getValue()+1, readfds, null, null, null);
if (err < 0) {
if (libc.Errno.EINTR == Native.getLastError()) {
continue;
}
break;
}
saAmfLib.saAmfDispatch(amfHandle.getValue(), saAis.SaAisLibrary.SaDispatchFlagsT.SA_DISPATCH_ALL);
}while(!unblockNow);
/*
* Do the application specific finalization here.
*/
rc = saAmfLib.saAmfFinalize(amfHandle.getValue());
if (rc != saAis.SaAisLibrary.SaAisErrorT.SA_AIS_OK) {
errorexit(rc,-1);
}
}
private static String haStateToString(int haState) {
switch (haState) {
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_ACTIVE:
return "Active";
case saAmf.SaAmfLibrary.SaAmfHaStateT. SA_AMF_HA_STANDBY:
return "Standby";
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_QUIESCED:
return "Quiesced";
case saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_QUIESCING:
return "Quiescing";
default:
return "Unknown";
}
}
private static String csiFlagsToString(int csiFlags) {
if ((csiFlags & saAmf.SaAmfLibrary.SA_AMF_CSI_ADD_ONE) != 0)
return "Add One";
if ((csiFlags & saAmf.SaAmfLibrary.SA_AMF_CSI_TARGET_ONE) != 0)
return "Target One";
if ((csiFlags & saAmf.SaAmfLibrary.SA_AMF_CSI_TARGET_ALL) != 0)
return "Target All";
return "Unknown";
}
/******************************************************************************
* Utility functions
*****************************************************************************/
/*
* clCompAppAMFPrintCSI
* --------------------
* Print information received in a CSI set request.
*/
private static void clCompAppAMFPrintCSI(saAmf.SaAmfCSIDescriptorT csiDescriptor,
int haState) {
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO,
"CSI Flags : [%s]",
csiFlagsToString(csiDescriptor.csiFlags));
if (saAmf.SaAmfLibrary.SA_AMF_CSI_TARGET_ALL != csiDescriptor.csiFlags) {
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("CSI Name : [%s]",
Native.toString(csiDescriptor.csiName.value)));
}
if (saAmf.SaAmfLibrary.SA_AMF_CSI_ADD_ONE == csiDescriptor.csiFlags) {
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, "Name value pairs :");
int count = csiDescriptor.csiAttr.number;
Pointer ptr = csiDescriptor.csiAttr.attr;
if (ptr != null && count > 0) {
saAmf.SaAmfCSIAttributeT[] attrs = (saAmf.SaAmfCSIAttributeT[]) new saAmf.SaAmfCSIAttributeT(ptr).toArray(count);
for (int i = 0; i < count; i++) {
attrs[i].read();
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Name :[%s]",attrs[i].getName()));
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Value : [%s]", attrs[i].getValue()));
}
}
}
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("HA state : [%s]",
haStateToString(haState)));
if (saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_ACTIVE == haState) {
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, "Active Descriptor :");
saAmf.SaAmfCSIActiveDescriptorT act = csiDescriptor.csiStateDescriptor.activeDescriptor;
act.read();
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO,
String.format("Transition Descriptor : [%d]",
act.transitionDescriptor));
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO,
String.format("Active Component : [%s]",
Native.toString(act.activeCompName.value)));
}
else if (saAmf.SaAmfLibrary.SaAmfHaStateT.SA_AMF_HA_STANDBY == haState) {
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, "Standby Descriptor :");
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO,
String.format("Standby Rank : [%d]",
csiDescriptor.csiStateDescriptor.
standbyDescriptor.standbyRank));
clprintf (clUtils.ClUtilsLibrary.ClLogSeverityT.CL_LOG_SEV_INFO, String.format("Active Component : [%s]",
Native.toString(csiDescriptor.csiStateDescriptor.
standbyDescriptor.activeCompName.value)));
}
}
/*
* Insert any other utility functions here.
*/
static class DhaDemoCreate implements Runnable {
public void run() {
if (!unblockNow) {
clDhaDemoCreate();
}
}
};
static void clDhaDemoCreateStart() {
DhaDemoCreate dhaDemoCreate = new DhaDemoCreate();
Thread dhaDemoCreateThread = new Thread(dhaDemoCreate);
dhaDemoCreateThread.start();
}
static class DhaDemoDelete implements Runnable {
public void run() {
if (!unblockNow) {
clDhaDemoDelete();
}
}
};
static void clDhaDemoDeleteStart() {
DhaDemoDelete dhaDemoDelete = new DhaDemoDelete();
Thread dhaDemoDeleteThread = new Thread(dhaDemoDelete);
dhaDemoDeleteThread.start();
}
static int clDhaDemoCreate() {
int rc = 0;
int retCode = 0;
long mgmtHandle = 0;
ClVersionT version = new ClVersionT();
version.releaseCode = 'B';
version.majorVersion = 1;
version.minorVersion = 1;
version.write();
long ccbHandle = 0;
String pBaseName = BASE_NAME;
clAmsMgmtClientApi.ClAmsEntityT entity = new clAmsMgmtClientApi.ClAmsEntityT();
PointerByReference pEntityConfig = new PointerByReference();
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO, "Running MGMT initialize");
LongByReference mgmtHdl = new LongByReference();
try {
rc = amsMgmtLib.clAmsMgmtInitialize(mgmtHdl, null, version.getPointer());
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR, "AmsMgmt initialize returned [%#x]", rc);
return rc;
}
mgmtHandle = mgmtHdl.getValue();
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Running MGMT CCB initialize");
LongByReference ccbHdl = new LongByReference();
rc = amsMgmtLib.clAmsMgmtCCBInitialize(mgmtHandle, ccbHdl);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR, "MGMT CCB initialize returned [%#x]", rc);
//rc = amsMgmtLib.clAmsMgmtFinalize(mgmtHandle);
return rc;
}
ccbHandle = ccbHdl.getValue();
/*
* Create the entities only if they are not created already
*/
String temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG, "%sSG", BASE_NAME, entity);
rc = amsMgmtLib.clAmsMgmtEntityGetConfig(mgmtHandle,
entity,
pEntityConfig);
utilsLib.clHeapFree(pEntityConfig.getValue());
if (rc == 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO, "Not creating SG[%sSG], it already exist", BASE_NAME);
return rc;
}
/* SG doesn't exist, create SG and other entities dynamically*/
/*First create the service hierarchies*/
clprintf(ClLogSeverityT.CL_LOG_SEV_NOTICE,
"Creating 2N SG [%sSG] and other entities(si, csi, su, comp, etc)",
BASE_NAME);
/* Create SG*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG,"%sSG", BASE_NAME, entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating SG [%s]", temp);
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SG [%s] create returned [%#x]",temp,rc);
return rc;
}
/* Create SI*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SI, "%sSI", BASE_NAME, entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating SI [%s]", temp);
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SI [%s] create returned [%#x]",temp,rc);
return rc;
}
/* Create CSI*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_CSI, "%sCSI", BASE_NAME, entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating CSI [%s]", temp);
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"CSI [%s] create returned [%#x]",temp,rc);
return rc;
}
/*Create 2 SUs*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SU,"%sSU0", BASE_NAME, entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating SU [%s]", temp);
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SU [%s] create returned [%#x]",temp,rc);
return rc;
}
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SU, "%sSU1", BASE_NAME,entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating SU [%s]", temp);
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SU [%s] create returned [%#x]",temp,rc);
return rc;
}
/*Create COMP*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_COMP, "%s0", NEW_COMP_PREFIX, entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating comp [%s]", Native.toString(entity.name.value));
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"Comp [%s] create returned [%#x]",temp,rc);
return rc;
}
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_COMP, "%s1", NEW_COMP_PREFIX, entity);
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Creating comp [%s]", Native.toString(entity.name.value));
rc = amsMgmtLib.clAmsMgmtCCBEntityCreate(ccbHandle, entity);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"Comp [%s] create returned [%#x]",temp,rc);
return rc;
}
/* CCB Commit*/
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"CCB Commit Create");
rc = amsMgmtLib.clAmsMgmtCCBCommit(ccbHandle);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"CCB Commit returned [%#x]", rc);
return rc;
}
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Fill SG config");
rc = clAmsMgmtTestFillConfig(mgmtHandle, ccbHandle, ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG, pBaseName);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SG config fill returned [%#x]", rc);
return rc;
}
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Fill SI config");
rc = clAmsMgmtTestFillConfig(mgmtHandle, ccbHandle, ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SI, pBaseName);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SI config fill returned [%#x]", rc);
}
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Fill CSI config");
rc = clAmsMgmtTestFillConfig(mgmtHandle, ccbHandle, ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_CSI, pBaseName);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"CSI config fill returned [%#x]", rc);
return rc;
}
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Fill SU config");
rc = clAmsMgmtTestFillConfig(mgmtHandle, ccbHandle, ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SU, pBaseName);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"SU config fill returned [%#x]", rc);
return rc;
}
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Fill NODE config");
rc = clAmsMgmtTestFillConfig(mgmtHandle, ccbHandle, ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_NODE, pBaseName);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"NODE config fill returned [%#x]", rc);
return rc;
}
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Fill COMP config");
rc = clAmsMgmtTestFillConfig(mgmtHandle, ccbHandle, ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_COMP, pBaseName);
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"COMP config fill returned [%#x]", rc);
return rc;
}
/*rc = clDhaExmpExec(
"Unlock " + temp,
() -> amsMgmtLib.clAmsMgmtEntityUnlock(mgmtHandle, entity),
err -> String.format("Unlock returned [%#x]", err));*/
final long CCB_HANDLE = ccbHandle;
final long MGMT_HANDLE = mgmtHandle;
rc = clDhaExmpExec(
"Unlock AMS entities",
() -> clAmsMgmtTestUnlock(MGMT_HANDLE, CCB_HANDLE, BASE_NAME),
err -> String.format("Unlock AMS entities returned [%#x]", err));
}
finally {
final long CCB_HANDLE = ccbHandle;
if (ccbHandle != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Running CCB finalize");
retCode = amsMgmtLib.clAmsMgmtCCBFinalize(ccbHandle);
if (retCode != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"CCB finalize returned [%#x]", retCode);
}
}
if (mgmtHandle != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Running MGMT finalize");
retCode = amsMgmtLib.clAmsMgmtFinalize(mgmtHandle);
if (retCode != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"MGMT finalize returned [%#x]", retCode);
}
}
if (rc == 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_NOTICE,"Successfully created 2N SG [%sSG] and its entities(si, csi, su, comp, etc) dynamically",
pBaseName);
}else {
clprintf(ClLogSeverityT.CL_LOG_SEV_CRITICAL, "Error while dynamically creating 2N SG [%sSG] and its entities(si, csi, su, comp, etc)",
pBaseName);
}
}
return rc;
}
static int clDhaDemoDelete() {
int rc = 0;
int retCode = 0;
long mgmtHandle = 0;
long ccbHandle = 0;
Pointer pointer = null;
ClVersionT version = new ClVersionT();
version.releaseCode = 'B';
version.majorVersion = 1;
version.minorVersion = 1;
version.write();
String pBaseName = BASE_NAME;
clAmsMgmtClientApi.ClAmsEntityT entity = new clAmsMgmtClientApi.ClAmsEntityT();
//clAmsMgmtClientApi.ClAmsEntityConfigT = new pEntityConfig = NULL;
PointerByReference pEntityConfig = new PointerByReference();
try {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO, "Running MGMT initialize");
LongByReference mgmtHdl = new LongByReference();
rc = amsMgmtLib.clAmsMgmtInitialize(mgmtHdl, null, version.getPointer());
if(rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR, "AmsMgmt initialize returned [%#x]", rc);
return rc;
}
mgmtHandle = mgmtHdl.getValue();
final long MGMT_HANDLE = mgmtHandle;
LongByReference ccbHdl = new LongByReference();
rc = clDhaExmpExec("Running MGMT CCB initialize",
() -> amsMgmtLib.clAmsMgmtCCBInitialize(MGMT_HANDLE, ccbHdl),
err -> String.format("MGMT CCB initialize returned [%#x]", err));
if (rc != 0) {
return rc;
}
ccbHandle = ccbHdl.getValue();
final long CCB_HANDLE = mgmtHandle;
/*
* Delete the entities only if they exist
*/
String temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG, "%sSG", pBaseName,entity);
rc = amsMgmtLib.clAmsMgmtEntityGetConfig(mgmtHandle,
entity,
pEntityConfig);
pointer = pEntityConfig.getValue();
utilsLib.clHeapFree(pointer);
if(rc != 0)
{
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO, "Not deleting SG[%sSG], SG config get returned [%#x]", pBaseName, rc);
return rc;
}
/* SG exist, Delete SG and other entities dynamically*/
clprintf(ClLogSeverityT.CL_LOG_SEV_NOTICE,
"Deleting SG [%sSG] and other entities(si, csi, su, comp, etc)",
pBaseName);
/*First move entities to lock instantiated mode*/
rc = clDhaExmpExec("LockI AMS entities",
() -> clAmsMgmtTestLockI(MGMT_HANDLE, CCB_HANDLE, BASE_NAME),
err -> String.format("Unlock AMS entities returned [%#x]", err));
if (rc != 0) {
return rc;
}
/*Delete 2 COMPs*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_COMP,"%s0", NEW_COMP_PREFIX,entity);
rc = clDhaExmpExec("Deleting COMP " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("COMP delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
temp = fillName(NEW_COMP_PREFIX, "%s1", entity.name);
rc = clDhaExmpExec("Deleting COMP " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("COMP delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
/*Delete 2 SUs*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SU, "%sSU0", NEW_COMP_PREFIX,entity);
rc = clDhaExmpExec("Deleting SU " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("SU delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
temp = fillName(pBaseName, "%sSU1", entity.name);
rc = clDhaExmpExec("Deleting SU " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("SU delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
/* Delete CSI*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_CSI, "%sCSI", pBaseName,entity);
rc = clDhaExmpExec("Deleting CSI " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("CSI delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
/* Delete SI*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SI, "%sSI", pBaseName,entity);
rc = clDhaExmpExec("Delete SI " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("SI delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
/* Delete SG*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG, "%sSG", pBaseName,entity);
rc = clDhaExmpExec("Deleting SG " + temp,
() -> amsMgmtLib.clAmsMgmtCCBEntityDelete(CCB_HANDLE, entity),
err -> String.format("SG delete returned [%#x]", err));
if (rc != 0) {
return rc;
}
/* CCB Commit*/
rc = clDhaExmpExec("CCB Commit Delete",
() -> amsMgmtLib.clAmsMgmtCCBCommit(CCB_HANDLE),
err -> String.format("CCB commit returned [%#x]", err));
}
finally {
if (ccbHandle != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Running CCB finalize");
retCode = amsMgmtLib.clAmsMgmtCCBFinalize(ccbHandle);
if (retCode != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"CCB finalize returned [%#x]", retCode);
}
}
if (mgmtHandle != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,"Running MGMT finalize");
retCode = amsMgmtLib.clAmsMgmtFinalize(mgmtHandle);
if (retCode != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR,"MGMT finalize returned [%#x]", retCode);
}
}
if (rc == 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_NOTICE,"Successfully deleted dynamically created SG [%sSG] and other entities(si, csi, su, comp, etc)",
pBaseName);
}else {
clprintf(ClLogSeverityT.CL_LOG_SEV_CRITICAL, "Error while deleting dynamically created SG [%sSG] and other entities(si, csi, su, comp, etc)",
pBaseName);
}
if (pointer != null) {
utilsLib.clHeapFree(pointer);
}
}
return rc;
}
/*static boolean clDhaExmpExec(String execInfo,
BooleanSupplier predicate,
String errorInfo) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,execInfo);
if (!predicate.getAsBoolean()) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR, errorInfo);
return false;
}
return true;
}*/
static int clDhaExmpExec(
String execInfo,
IntSupplier action,
IntFunction<String> errorInfo) {
clprintf(ClLogSeverityT.CL_LOG_SEV_INFO,execInfo);
int rc = action.getAsInt();
if (rc != 0) {
clprintf(ClLogSeverityT.CL_LOG_SEV_ERROR, errorInfo.apply(rc));
}
return rc;
}
static int clAmsMgmtTestUnlock(long mgmtHandle,
long ccbHandle,
String pBaseName) {
int rc = 0;
clAmsMgmtClientApi.ClAmsEntityT entity = new clAmsMgmtClientApi.ClAmsEntityT();
/*
* Step 1 - Unlock SUs
*/
String temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SU, "%sSU0", pBaseName, entity);
/*if (!clDhaExmpExec("LockA "+ entity.name.value,
() -> (rc = amsMgmtLib.clAmsMgmtEntityLockAssignment(mgmtHandle,
entity)) == 0,
String.format("LockA returned [%#x]", rc))) {
return rc;
}*/
rc = clDhaExmpExec(
"LockA " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(mgmtHandle, entity),
err -> String.format("LockA returned [%#x]", err));
if (rc != 0) {
return rc;
}
rc = clDhaExmpExec(
"Unlock " + temp,
() -> amsMgmtLib.clAmsMgmtEntityUnlock(mgmtHandle, entity),
err -> String.format("Unlock returned [%#x]", err));
if (rc != 0) {
return rc;
}
temp = fillName(pBaseName, "%sSU1", entity.name);
rc = clDhaExmpExec(
"LockA " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(mgmtHandle, entity),
err -> String.format("LockA returned [%#x]", err));
if (rc != 0) {
return rc;
}
rc = clDhaExmpExec(
"Unlock " + temp,
() -> amsMgmtLib.clAmsMgmtEntityUnlock(mgmtHandle, entity),
err -> String.format("Unlock returned [%#x]", err));
if (rc != 0) {
return rc;
}
/*
* Step 2 - Unlock SI
*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SI, "%sSI", pBaseName, entity);
rc = clDhaExmpExec(
"Unlock SI " + temp,
() -> amsMgmtLib.clAmsMgmtEntityUnlock(mgmtHandle, entity),
err -> String.format("Unlock SI returned [%#x]", err));
if (rc != 0) {
return rc;
}
/*
* Step 3 - Unlock SG
*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG, "%sSG", pBaseName, entity);
rc = clDhaExmpExec(
"LockA SG " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(mgmtHandle, entity),
err -> String.format("LockA SG returned [%#x]", err));
if (rc != 0) {
return rc;
}
rc = clDhaExmpExec(
"Unlock SG " + temp,
() -> amsMgmtLib.clAmsMgmtEntityUnlock(mgmtHandle, entity),
err -> String.format("Unlock SG returned [%#x]", err));
return rc;
}
static int clAmsMgmtTestLockI(long mgmtHandle,
long ccbHandle,
String pBaseName) {
int rc = 0;
clAmsMgmtClientApi.ClAmsEntityT entity = new clAmsMgmtClientApi.ClAmsEntityT();
/*
* Step 1 - Lock, Lock_I SUs
*/
String temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SU, "%sSU0", pBaseName,entity);
rc = clDhaExmpExec("LockA " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(ccbHandle, entity),
err -> String.format("LockA returned [%#x]", err));
if (rc != 0) {
return rc;
}
rc = clDhaExmpExec("LockI " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockInstantiation(ccbHandle, entity),
err -> String.format("LockI returned [%#x]", err));
if (rc != 0) {
return rc;
}
temp = fillName(pBaseName, "%sSU1", entity.name);
rc = clDhaExmpExec("LockA " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(ccbHandle, entity),
err -> String.format("LockA returned [%#x]", err));
if (rc != 0) {
return rc;
}
rc = clDhaExmpExec("LockI " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockInstantiation(ccbHandle, entity),
err -> String.format("LockI returned [%#x]", err));
if (rc != 0) {
return rc;
}
/*
* Step 2 - Lock SI
*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SI, "%sSI", pBaseName,entity);
rc = clDhaExmpExec("LockA SI " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(ccbHandle, entity),
err -> String.format("LockA returned [%#x]", err));
if (rc != 0) {
return rc;
}
/*
* Step 3 - Lock, Lock_I SG
*/
temp = fillEntity(ClAmsEntityTypeT.CL_AMS_ENTITY_TYPE_SG, "%sSG", pBaseName,entity);
rc = clDhaExmpExec("LockA SG " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockAssignment(ccbHandle, entity),
err -> String.format("LockA returned [%#x]", err));
if (rc != 0) {
return rc;
}
rc = clDhaExmpExec("LockI SG " + temp,
() -> amsMgmtLib.clAmsMgmtEntityLockInstantiation(ccbHandle,entity),
err -> String.format("LockI returned [%#x]", err));
return rc;
}
static String fillEntity(int type, String fmt, String pBaseName, clAmsMgmtClientApi.ClAmsEntityT entity) {
entity.type = type;
String temp = String.format(fmt, pBaseName);
byte[] bytes = temp.getBytes(StandardCharsets.UTF_8);
//entity.name.value = bytes;
Arrays.fill(entity.name.value, (byte)0);
entity.name.length = (short)bytes.length;
System.arraycopy(bytes, 0, entity.name.value, 0, entity.name.length);
entity.name.write();
entity.write();
return temp;
}
static void fillName(String name, ClNameT entName) {
byte[] bytes = name.getBytes(StandardCharsets.UTF_8);
//entName.value = bytes;
Arrays.fill(entName.value, (byte)0);
//entName.clear();
entName.length = (short) bytes.length;
System.arraycopy(bytes, 0, entName.value, 0, entName.length);
entName.write();
}
static String fillName(byte[] name, String fmt, ClNameT entName) {
String temp = Native.toString(name);
temp = fillName(temp, fmt, entName);
return temp;
}
static String fillName(String name, String fmt, ClNameT entName) {
String temp = String.format(fmt,name);
byte[] bytes = temp.getBytes(StandardCharsets.UTF_8);
//entName.value = bytes;
Arrays.fill(entName.value, (byte)0);
//entName.clear();
entName.length = (short) bytes.length;
System.arraycopy(bytes, 0, entName.value, 0, entName.length);
entName.write();
return temp;
}
static int clAmsMgmtTestFillConfig(long mgmtHandle,
long ccbHandle,
int type,
String pBaseName) {
int rc = 0;
clAmsMgmtClientApi.ClAmsEntityT entity = new clAmsMgmtClientApi.ClAmsEntityT();
clAmsMgmtClientApi.ClAmsEntityT targetEntity = new clAmsMgmtClientApi.ClAmsEntityT();
//clAmsMgmtClientApi.ClAmsEntityConfigT pEntityConfig = new clAmsMgmtClientApi.ClAmsEntityConfigT();
PointerByReference pEntityConfig = new PointerByReference();
Pointer pointer = null;
entity.type = type;
switch (type) {