summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Internal.ice
blob: 424482156ed5c1df5b2aa68eb0b6884fad56e745 (plain)
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
// **********************************************************************
//
// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#pragma once

[["cpp:header-ext:h"]]

#include <Ice/Identity.ice>
#include <Ice/BuiltinSequences.ice>
#include <Ice/ProcessF.ice>
#include <Ice/Properties.ice>

#include <Glacier2/Session.ice>
#include <IceGrid/Admin.ice>
#include <IceGrid/Registry.ice>

module IceGrid
{

local exception SynchronizationException
{
};

class InternalDbEnvDescriptor
{
    /** The name of the database environment. */
    string name;

    /** The database properties. */
    PropertyDescriptorSeq properties;
};
sequence<InternalDbEnvDescriptor> InternalDbEnvDescriptorSeq;

class InternalAdapterDescriptor
{
    /** The identifier of the server. */
    string id;

    /** Specifies if the lifetime of the adapter is the same as the server. */
    bool serverLifetime;
};
sequence<InternalAdapterDescriptor> InternalAdapterDescriptorSeq;

class InternalDistributionDescriptor
{
    /** The proxy of the IcePatch2 server. */
    string icepatch;

    /** The source directories. */
    ["java:type:java.util.LinkedList<String>"] Ice::StringSeq directories;
};

dictionary<string, PropertyDescriptorSeq> PropertyDescriptorSeqDict;

class InternalServerDescriptor
{
    /** The server ID. */
    string id;

    /** The server application */
    string application;

    /** The application uuid. */
    string uuid;

    /** The application revision. */
    int revision;

    /** The id of the session which allocated the server. */
    string sessionId;

    /** The server executable. */
    string exe;

    /** The server working directory. */
    string pwd;

    /** The user ID to use to run the server. */
    string user;

    /** The server activation mode. */
    string activation;

    /** The server activation timeout. */
    string activationTimeout;

    /** The server deactivation timeout. */
    string deactivationTimeout;

    /** Specifies if the server depends on the application distrib. */
    bool applicationDistrib;

    /** The distribution descriptor of this server. */
    InternalDistributionDescriptor distrib;

    /** Specifies if a process object is registered. */
    bool processRegistered;

    /** The server command line options. */
    Ice::StringSeq options;

    /** The server environment variables. */
    Ice::StringSeq envs;

    /** The path of the server logs. */
    Ice::StringSeq logs;

    /** The indirect object adapters. */
    InternalAdapterDescriptorSeq adapters;

    /** The database environments. */
    InternalDbEnvDescriptorSeq dbEnvs;

    /** The configuration files of the server. */
    PropertyDescriptorSeqDict properties;

    /** IceBox service names */
    optional(1) Ice::StringSeq services;
};

/**
 *
 * This exception is raised if an adapter is active.
 *
 **/
exception AdapterActiveException
{
};

exception AdapterNotActiveException
{
    /** True if the adapter can be activated on demand. */
    bool activatable;
};

interface Adapter
{
    /**
     *
     * Activate this adapter. If this adapter can be activated, this
     * will activate the adapter and return the direct proxy of the
     * adapter once it's active. If this adapter can be activated on
     * demand, this will return 0 if the adapter is inactive or the
     * adapter direct proxy it's active.
     *
     **/
    ["amd"] Object* activate();

    /**
     *
     * Get the adapter direct proxy. The adapter direct proxy is a
     * proxy created with the object adapter. The proxy contains the
     * last known adapter endpoints.
     *
     * @return A direct proxy containing the last known adapter
     * endpoints if the adapter is already active.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent Object* getDirectProxy()
        throws AdapterNotActiveException;

    /**
     *
     * Set the direct proxy for this adapter.
     *
     * @param The direct proxy. The direct proxy should be created
     * with the object adapter and should contain the object adapter
     * endpoints.
     *
     * @throws AdapterActiveException The adapter is already
     * active. It's not possible to override the direct proxy of an
     * active adapter.
     *
     **/
    void setDirectProxy(Object* proxy)
        throws AdapterActiveException;
};

/**
 *
 * This exception is raised if an adapter with the same name already
 * exists.
 *
 **/
exception AdapterExistsException
{
    string id;
};

dictionary<string, Adapter*> AdapterPrxDict;

interface FileReader
{
    /**
     *
     * Count the number of given lines from the end of the file and
     * return the file offset.
     *
     **/
    ["cpp:const"] idempotent long getOffsetFromEnd(string filename, int lines)
        throws FileNotAvailableException;

    /**
     *
     * Read lines (or size bytes) at the specified position from the given file.
     *
     **/
    ["cpp:const"] idempotent bool read(string filename, long pos, int size, out long newPos, out Ice::StringSeq lines)
        throws FileNotAvailableException;
};

interface Server extends FileReader
{
    /**
     *
     * Start the server.
     *
     * @return True if the server was successfully started, false
     * otherwise.
     *
     **/
    ["amd"] void start()
        throws ServerStartException;

    /**
     *
     * Stop the server. This methods returns only when the server is
     * deactivated. If the server doesn't stop after a configurable
     * amount of time, it will be killed.
     *
     **/
    ["amd"] void stop()
        throws ServerStopException;

    /**
     *
     * Check if the given server can be loaded on this node.
     *
     * @return True if the server is inactive.
     *
     * @throws DeploymentException Raised if the server can't be updated.
     *
     **/
    bool checkUpdate(InternalServerDescriptor svr, bool noRestart)
        throws DeploymentException;

    /**
     *
     * Enable or disable the server.
     *
     **/
    void setEnabled(bool enable);

    /**
     *
     * Check if the server is enabled.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent bool isEnabled();

    /**
     *
     * Send signal to the server
     *
     **/
    void sendSignal(string signal)
        throws BadSignalException;

    /**
     *
     * Write message on servers' stdout or stderr.
     *
     **/
    void writeMessage(string message, int fd);

    /**
     *
     * Return the server state.
     *
     * @return The server state.
     *
     * @see ServerState
     *
     **/
    ["nonmutating", "cpp:const"] idempotent ServerState getState();

    /**
     *
     * Get the server pid. Note that the value returned by this method
     * is system dependant. On Unix operating systems, it's the pid
     * value returned by the fork() system call and converted to an
     * integer.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent int getPid();

    /**
     *
     * Set the process proxy.
     *
     **/
    ["amd"] void setProcess(Ice::Process* proc);
};

interface InternalRegistry;
sequence<InternalRegistry*> InternalRegistryPrxSeq;

interface ReplicaObserver
{
    /**
     *
     * Initialization of the replica observer.
     *
     **/
    void replicaInit(InternalRegistryPrxSeq replicas);

    /**
     *
     * Notification that a replica has been added. The node should
     * establish a session with this new replica.
     *
     **/
    void replicaAdded(InternalRegistry* replica);

    /**
     *
     * Notification that a replica has been removed. The node should
     * destroy the session to this replica.
     *
     **/
    void replicaRemoved(InternalRegistry* replica);
};

interface PatcherFeedback
{
    /**
     *
     * The patch completed successfully.
     *
     **/
    void finished();

    /**
     *
     * The patch on the given node failed for the given reason.
     *
     **/
    void failed(string reason);
};

interface Node extends FileReader, ReplicaObserver
{
    /**
     *
     * Load the given server. If the server resources weren't already
     * created (database environment directories, property files, etc),
     * they will be created.
     *
     **/
    ["amd"] idempotent Server* loadServer(InternalServerDescriptor svr,
                                                 string replicaName,
                                                 out AdapterPrxDict adapters,
                                                 out int actTimeout,
                                                 out int deactTimeout)
        throws DeploymentException;

    /**
     *
     * Load the given server and ensure the server won't be
     * restarted. If the server resources weren't already created
     * (database environment directories, property files, etc), they
     * will be created. If the server can't be updated without a
     * restart, a DeploymentException is raised.
     *
     **/
    ["amd"] idempotent Server* loadServerWithoutRestart(InternalServerDescriptor svr,
                                                        string replicaName,
                                                        out AdapterPrxDict adapters,
                                                        out int actTimeout,
                                                        out int deactTimeout)
        throws DeploymentException;

    /**
     *
     * Destroy the given server.
     *
     **/
    ["amd"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName)
        throws DeploymentException;

    /**
     *
     * Destroy the server if it's not active.
     *
     **/
    ["amd"] idempotent void destroyServerWithoutRestart(string name, string uuid, int revision, string replicaName)
        throws DeploymentException;

    /**
     *
     * Patch application and server distributions. If some servers
     * using a distribution directory to patch are active, this method
     * will raise a PatchException unless shutdown is set to true. In
     * which case the servers will be shutdown.
     *
     **/
    ["amd"] idempotent void patch(PatcherFeedback* feedback,
                                  string application,
                                  string server,
                                  InternalDistributionDescriptor appDistrib,
                                  bool shutdown);

    /**
     *
     * Establish a session to the given replica, this method only
     * returns once the registration was attempted (unlike
     * replicaAdded below).
     *
     **/
    void registerWithReplica(InternalRegistry* replica);

    /**
     *
     * Get the node name.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent string getName();

    /**
     *
     * Get the node hostname.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent string getHostname();

    /**
     *
     * Get the node load.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent LoadInfo getLoad();

    /**
     *
     * Get the number of processor sockets for the machine where this
     * node is running.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent int getProcessorSocketCount();

    /**
     *
     * Shutdown the node.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent void shutdown();
};

sequence<Node*> NodePrxSeq;

/**
 *
 * This exception is raised if a node is already registered and
 * active.
 *
 **/
exception NodeActiveException
{
};

interface NodeSession
{
    /**
     *
     * The node call this method to keep the session alive.
     *
     **/
    void keepAlive(LoadInfo load);

    /**
     *
     * Set the replica observer. The node calls this method when it's
     * ready to receive notifications for the replicas. It only calls
     * this for the session with the master.
     *
     **/
    void setReplicaObserver(ReplicaObserver* observer);

    /**
     *
     * Return the node session timeout.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent int getTimeout();

    /**
     *
     * Return the node observer.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent NodeObserver* getObserver();

    /**
     *
     * Ask the registry to load the servers on the node.
     *
     **/
    ["amd", "nonmutating", "cpp:const"] idempotent void loadServers();

    /**
     *
     * Get the name of the servers deployed on the node.
     *
     **/
    ["nonmutating", "cpp:const"] idempotent Ice::StringSeq getServers();

    /**
     *
     * Wait for the application update to complete (the application is
     * completely updated once all the registry replicas have been
     * updated). This is used by the node to ensure that before to
     * start a server all the replicas have the up-to-date descriptor
     * of the server.
     *
     **/
    ["amd", "cpp:const"] void waitForApplicationUpdate(string application, int revision);

    /**
     *
     * Destroy the session.
     *
     **/
    void destroy();
};

/**
 *
 * This exception is raised if a replica is already registered and
 * active.
 *
 **/
exception ReplicaActiveException
{
};

enum TopicName
{
    RegistryObserverTopicName,
    NodeObserverTopicName,
    ApplicationObserverTopicName,
    AdapterObserverTopicName,
    ObjectObserverTopicName
};

interface DatabaseObserver extends ApplicationObserver, ObjectObserver, AdapterObserver
{
};

dictionary<string, long> StringLongDict;

interface ReplicaSession
{
    /**
     *
     * The replica call this method to keep the session alive.
     *
     **/
    void keepAlive();

    /**
     *
     * Return the replica session timeout.
     *
     **/
    ["cpp:const"] idempotent int getTimeout();

    /**
     *
     * Set the database observer. Once the observer is subscribed, it
     * will receive the database and database updates.
     *
     **/
    idempotent void setDatabaseObserver(DatabaseObserver* dbObs, optional(1) StringLongDict serials)
        throws ObserverAlreadyRegisteredException, DeploymentException;

    /**
     *
     * This method sets the endpoints of the replica. This allows the
     * master to create proxies with multiple endpoints for replicated
     * objects (e.g.: IceGrid::Query object).
     *
     **/
    idempotent void setEndpoints(StringObjectProxyDict endpoints);

    /**
     *
     * Registers the replica well-known objects with the master.
     *
     **/
    idempotent void registerWellKnownObjects(ObjectInfoSeq objects);

    /**
     *
     * Set the adapter direct proxy of the given adapter in the
     * master. This is used to support dynamic registration with
     * the locator registry interface.
     *
     **/
    idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy)
        throws AdapterNotExistException, AdapterExistsException;

    /**
     *
     * Notify the master that an update was received. The master might
     * wait for replication updates to be received by all the replicas
     * before to continue.
     *
     **/
    void receivedUpdate(TopicName name, int serial, string failure);

    /**
     *
     * Destroy the session.
     *
     **/
    void destroy();
};

/**
 *
 * Information about an IceGrid node.
 *
 **/
class InternalNodeInfo
{
    /**
     *
     * The name of the node.
     *
     **/
    string name;

    /**
     *
     * The operating system name.
     *
     **/
    string os;

    /**
     *
     * The network name of the host running this node (as defined in
     * uname()).
     *
     **/
    string hostname;

    /**
     *
     * The operation system release level (as defined in uname()).
     *
     **/
    string release;

    /**
     *
     * The operation system version (as defined in uname()).
     *
     **/
    string version;

    /**
     *
     * The machine hardware type (as defined in uname()).
     *
     **/
    string machine;

    /**
     *
     * The number of processor threads (e.g. 8 on
     * system with 1 quad-core CPU, with 2 threads per core)
     *
     **/
    int nProcessors;

    /**
     *
     * The path to the node data directory.
     *
     **/
    string dataDir;
};

/**
 *
 * Information about an IceGrid registry replica.
 *
 **/
class InternalReplicaInfo
{
    /**
     *
     * The name of the registry.
     *
     **/
    string name;

    /**
     *
     * The network name of the host running this registry (as defined in
     * uname()).
     *
     **/
    string hostname;
};

interface InternalRegistry extends FileReader
{
    /**
     *
     * Register a node with the registry. If a node with the same name
     * is already registered, [registerNode] will overide the previous
     * node only if it's not active.
     *
     * @param info Some information on the node.
     *
     * @param prx The proxy of the node.
     *
     * @param loadInf The load information of the node.
     *
     * @return The node session proxy.
     *
     * @throws NodeActiveException Raised if the node is already
     * registered and currently active.
     *
     **/
    NodeSession* registerNode(InternalNodeInfo info, Node* prx, LoadInfo loadInf)
        throws NodeActiveException, PermissionDeniedException;

    /**
     *
     * Register a replica with the registry. If a replica with the
     * same name is already registered, [registerReplica] will overide
     * the previous replica only if it's not active.
     *
     * @param info Some information on the replica.
     *
     * @param prx The proxy of the replica.
     *
     * @return The replica session proxy.
     *
     * @throws ReplicaActiveException Raised if the replica is already
     * registered and currently active.
     *
     **/
    ReplicaSession* registerReplica(InternalReplicaInfo info, InternalRegistry* prx)
        throws ReplicaActiveException, PermissionDeniedException;

    /**
     *
     * Create a session with the given registry replica. This method
     * returns only once the session creation has been attempted.
     *
     **/
    void registerWithReplica(InternalRegistry* prx);

    /**
     *
     * Return the proxies of all the nodes known by this registry.
     *
     **/
    ["cpp:const"] idempotent NodePrxSeq getNodes();

    /**
     *
     * Return the proxies of all the registry replicas known by this
     * registry.
     *
     **/
    ["cpp:const"] idempotent InternalRegistryPrxSeq getReplicas();

    /**
     *
     * Return applications, adapters, objects from this replica.
     *
     **/
    ["cpp:const"] idempotent ApplicationInfoSeq getApplications(out long serial);
    ["cpp:const"] idempotent AdapterInfoSeq getAdapters(out long serial);
    ["cpp:const"] idempotent ObjectInfoSeq getObjects(out long serial);

    /**
     *
     * Shutdown this registry.
     *
     **/
    ["cpp:const"] idempotent void shutdown();
};


};