@@ -1009,177 +1009,6 @@ static void JS_FiguresVocbaseCol(
1009
1009
TRI_V8_TRY_CATCH_END
1010
1010
}
1011
1011
1012
- // //////////////////////////////////////////////////////////////////////////////
1013
- // / @brief was docuBlock assumeLeadership
1014
- // //////////////////////////////////////////////////////////////////////////////
1015
-
1016
- static void JS_SetTheLeader (v8::FunctionCallbackInfo<v8::Value> const & args) {
1017
- TRI_V8_TRY_CATCH_BEGIN (isolate);
1018
- v8::HandleScope scope (isolate);
1019
- auto & vocbase = GetContextVocBase (isolate);
1020
-
1021
- if (vocbase.isDropped ()) {
1022
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
1023
- }
1024
-
1025
- if (ServerState::instance ()->isDBServer ()) {
1026
- auto * v8Collection = UnwrapCollection (args.Holder ());
1027
-
1028
- if (!v8Collection) {
1029
- TRI_V8_THROW_EXCEPTION_INTERNAL (" cannot extract collection" );
1030
- }
1031
-
1032
- auto & collectionName = v8Collection->name ();
1033
- auto collection = v8Collection->vocbase ().lookupCollection (collectionName);
1034
-
1035
- if (collection == nullptr ) {
1036
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
1037
- }
1038
-
1039
- std::string theLeader;
1040
-
1041
- if (args.Length () >= 1 && args[0 ]->IsString ()) {
1042
- TRI_Utf8ValueNFC l (args[0 ]);
1043
- theLeader = std::string (*l, l.length ());
1044
- }
1045
-
1046
- collection->followers ()->setTheLeader (theLeader);
1047
-
1048
- if (theLeader.empty ()) {
1049
- collection->followers ()->clear ();
1050
- }
1051
- // do not reset followers when we resign at this time...we are
1052
- // still the only source of truth to trust, in particular, in the
1053
- // planned leader resignation, we will shortly after the call to
1054
- // this function here report the controlled resignation to the
1055
- // agency. This report must still contain the correct follower list
1056
- // or else the supervision is super angry with us.
1057
- }
1058
-
1059
- TRI_V8_RETURN_UNDEFINED ();
1060
- TRI_V8_TRY_CATCH_END
1061
- }
1062
-
1063
- // //////////////////////////////////////////////////////////////////////////////
1064
- // / @brief was docuBlock getLeader
1065
- // //////////////////////////////////////////////////////////////////////////////
1066
-
1067
- static void JS_GetLeader (v8::FunctionCallbackInfo<v8::Value> const & args) {
1068
- TRI_V8_TRY_CATCH_BEGIN (isolate);
1069
- v8::HandleScope scope (isolate);
1070
- auto & vocbase = GetContextVocBase (isolate);
1071
-
1072
- if (vocbase.isDropped ()) {
1073
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
1074
- }
1075
-
1076
- std::string theLeader;
1077
- if (ServerState::instance ()->isDBServer ()) {
1078
- auto * collection = UnwrapCollection (args.Holder ());
1079
-
1080
- if (!collection) {
1081
- TRI_V8_THROW_EXCEPTION_INTERNAL (" cannot extract collection" );
1082
- }
1083
-
1084
- auto & collectionName = collection->name ();
1085
- auto realCollection =
1086
- collection->vocbase ().lookupCollection (collectionName);
1087
-
1088
- if (realCollection == nullptr ) {
1089
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
1090
- }
1091
-
1092
- theLeader = realCollection->followers ()->getLeader ();
1093
- }
1094
-
1095
- v8::Handle<v8::String> res = TRI_V8_STD_STRING (isolate, theLeader);
1096
- TRI_V8_RETURN (res);
1097
- TRI_V8_TRY_CATCH_END
1098
- }
1099
-
1100
- // //////////////////////////////////////////////////////////////////////////////
1101
- // / @brief was docuBlock removeFollower
1102
- // //////////////////////////////////////////////////////////////////////////////
1103
-
1104
- static void JS_RemoveFollower (v8::FunctionCallbackInfo<v8::Value> const & args) {
1105
- TRI_V8_TRY_CATCH_BEGIN (isolate);
1106
- v8::HandleScope scope (isolate);
1107
- auto & vocbase = GetContextVocBase (isolate);
1108
-
1109
- if (vocbase.isDropped ()) {
1110
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
1111
- }
1112
-
1113
- if (args.Length () < 1 ) {
1114
- TRI_V8_THROW_EXCEPTION_USAGE (" removeFollower(<name>)" );
1115
- }
1116
-
1117
- ServerID const serverId = TRI_ObjectToString (args[0 ]);
1118
-
1119
- if (ServerState::instance ()->isDBServer ()) {
1120
- auto * v8Collection = UnwrapCollection (args.Holder ());
1121
-
1122
- if (!v8Collection) {
1123
- TRI_V8_THROW_EXCEPTION_INTERNAL (" cannot extract collection" );
1124
- }
1125
-
1126
- auto & collectionName = v8Collection->name ();
1127
- auto collection = v8Collection->vocbase ().lookupCollection (collectionName);
1128
-
1129
- if (collection == nullptr ) {
1130
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
1131
- }
1132
-
1133
- collection->followers ()->remove (serverId);
1134
- }
1135
-
1136
- TRI_V8_RETURN_TRUE ();
1137
- TRI_V8_TRY_CATCH_END
1138
- }
1139
-
1140
- // //////////////////////////////////////////////////////////////////////////////
1141
-
F438
// / @brief was docuBlock getFollowers
1142
- // //////////////////////////////////////////////////////////////////////////////
1143
-
1144
- static void JS_GetFollowers (v8::FunctionCallbackInfo<v8::Value> const & args) {
1145
- TRI_V8_TRY_CATCH_BEGIN (isolate);
1146
- v8::HandleScope scope (isolate);
1147
-
1148
- auto & vocbase = GetContextVocBase (isolate);
1149
-
1150
- if (vocbase.isDropped ()) {
1151
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
1152
- }
1153
-
1154
- v8::Handle<v8::Array> list = v8::Array::New (isolate);
1155
-
1156
- if (ServerState::instance ()->isDBServer ()) {
1157
- auto * v8Collection = UnwrapCollection (args.Holder ());
1158
-
1159
- if (!v8Collection) {
1160
- TRI_V8_THROW_EXCEPTION_INTERNAL (" cannot extract collection" );
1161
- }
1162
-
1163
- auto & collectionName = v8Collection->name ();
1164
- auto collection = v8Collection->vocbase ().lookupCollection (collectionName);
1165
-
1166
- if (collection == nullptr ) {
1167
- TRI_V8_THROW_EXCEPTION (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND);
1168
- }
1169
-
1170
- std::unique_ptr<arangodb::FollowerInfo> const & followerInfo = collection->followers ();
1171
- std::shared_ptr<std::vector<ServerID> const > followers = followerInfo->get ();
1172
- uint32_t i = 0 ;
1173
-
1174
- for (auto const & n : *followers) {
1175
- list->Set (i++, TRI_V8_STD_STRING (isolate, n));
1176
- }
1177
- }
1178
-
1179
- TRI_V8_RETURN (list);
1180
- TRI_V8_TRY_CATCH_END
1181
- }
1182
-
1183
1012
// //////////////////////////////////////////////////////////////////////////////
1184
1013
// / @brief was docuBlock collectionLoad
1185
1014
// //////////////////////////////////////////////////////////////////////////////
@@ -2732,14 +2561,6 @@ void TRI_InitV8Collections(v8::Handle<v8::Context> context,
2732
2561
JS_InsertVocbaseCol);
2733
2562
TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " _binaryInsert" ),
2734
2563
JS_BinaryInsertVocbaseCol);
2735
- TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " setTheLeader" ),
2736
- JS_SetTheLeader, true );
2737
- TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " getLeader" ),
2738
- JS_GetLeader, true );
2739
- TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " removeFollower" ),
2740
- JS_RemoveFollower, true );
2741
- TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " getFollowers" ),
2742
- JS_GetFollowers, true );
2743
2564
TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " globallyUniqueId" ),
2744
2565
JS_GloballyUniqueIdVocbaseCol);
2745
2566
TRI_AddMethodVocbase (isolate, rt, TRI_V8_ASCII_STRING (isolate, " load" ),
0 commit comments