UNPKG

graphdb-workbench

Version:
2 lines 8.96 kB
export const __webpack_id__=24508;export const __webpack_ids__=[24508];export const __webpack_modules__={24508:(t,e,s)=>{s.r(e),s.d(e,{ClusterConfiguration:()=>u,ClusterItemViewModel:()=>l,ClusterModel:()=>a,ClusterViewModel:()=>d,Link:()=>o,Location:()=>i,Node:()=>r,TopologyStatus:()=>n});class i{constructor(t,e=null,s=null,i=!1,r=!1){this._endpoint=t,this._rpcAddress=e,this._error=s,this._isAvailable=i,this._isLocal=r}get isLocal(){return this._isLocal}get endpoint(){return this._endpoint}get rpcAddress(){return this._rpcAddress}get error(){return this._error}get isAvailable(){return this._isAvailable}set endpoint(t){this._endpoint=t}set rpcAddress(t){this._rpcAddress=t}set error(t){this._error=t}set isAvailable(t){this._isAvailable=t}set isLocal(t){this._isLocal=t}static fromJSON({endpoint:t,rpcAddress:e,error:s=null,isAvailable:r=!1,isLocal:n=!1}){return new i(t,e,s,r,n)}}class r{constructor(t,e,s,i,r,o,a,d,l){this._address=t,this._nodeState=e,this._term=s,this._syncStatus=i,this._lastLogTerm=r,this._lastLogIndex=o,this._endpoint=a,this._recoveryStatus=d,this._topologyStatus=n.fromJSON(l)}get address(){return this._address}get nodeState(){return this._nodeState}get term(){return this._term}get syncStatus(){return this._syncStatus}get lastLogTerm(){return this._lastLogTerm}get lastLogIndex(){return this._lastLogIndex}get endpoint(){return this._endpoint}get recoveryStatus(){return this._recoveryStatus}set address(t){this._address=t}set nodeState(t){this._nodeState=t}set term(t){this._term=t}set syncStatus(t){this._syncStatus=t}set lastLogTerm(t){this._lastLogTerm=t}set lastLogIndex(t){this._lastLogIndex=t}set endpoint(t){this._endpoint=t}set recoveryStatus(t){this._recoveryStatus=t}get topologyStatus(){return this._topologyStatus}set topologyStatus(t){return this._topologyStatus=t}static fromJSON({address:t,nodeState:e,term:s,syncStatus:i,lastLogTerm:n,lastLogIndex:o,endpoint:a,recoveryStatus:d,topologyStatus:l}){return new r(t,e,s,i,n,o,a,d,l)}}class n{constructor(t,e=new Map,s,i){this._state=t,this._primaryTags=e,this._primaryIndex=s,this._primaryLeader=i}get state(){return this._state}get primaryTags(){return this._primaryTags}get primaryIndex(){return this._primaryIndex}get primaryLeader(){return this._primaryLeader}static fromJSON({state:t,primaryTags:e={},primaryIndex:s,primaryLeader:i}){const r=Object.entries(e);return new n(t,r,s,i)}}class o{constructor(t,e,s,i){this._id=t,this._source=e,this._target=s,this._status=i}static fromJSON({id:t,source:e,target:s,status:i}){return new o(t,e,s,i)}}class a{constructor(t,e,s,i){this._locations=t,this._hasCluster=e,this._nodes=s,this._links=i}get locations(){return this._locations}set locations(t){this._locations=t}get hasCluster(){return this._hasCluster}set hasCluster(t){this._hasCluster=t}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get links(){return this._links}set links(t){this._links=t}static fromJSON(t){const e=t.locations.map(i.fromJSON),s=t.nodes.map(r.fromJSON),n=t.links.map(o.fromJSON);return new a(e,t.hasCluster,s,n)}}class d{constructor(t){this._clusterModel=a.fromJSON(t),this._addToCluster=new Map,this._deleteFromCluster=new Map,this._currentNodesCount=0,this._clusterConfiguration=new u,this._localNodeEndpoint=t.locations.find(t=>t.isLocal).endpoint,this.MINIMUM_NODES_REQUIRED=2}getAttached(){const t=this._clusterModel.nodes.concat(Array.from(this._addToCluster.values()));return this._currentNodesCount=t.filter(t=>!this._deleteFromCluster.has(t.endpoint)).length,t}getViewModel(){let t=0;return this.getAttached().map(e=>{const s=new l(e);return this._deleteFromCluster.has(e.endpoint)?s.isDeleted=!0:s.index=t++,this._localNodeEndpoint===e.endpoint&&(s.isLocal=!0),s})}getAvailable(t=!1){const e=this._clusterModel.nodes;return this._clusterModel.locations.filter(s=>{const i=!this.isPresentInList(e,s.endpoint),r=s.isAvailable,n=!this._addToCluster.has(s.endpoint),o=!!t||!this._deleteFromCluster.has(s.endpoint);return i&&r&&o&&n})}getAvailableNodeEndpoints(){return this.getAvailable().map(t=>t.endpoint)}getLocalNode(){return this._clusterModel.locations.find(t=>t.isLocal)}addToCluster(t){const e=t.endpoint;t.endpoint&&this.addToLocations(t),this._deleteFromCluster.has(e)?this._deleteFromCluster.delete(e):this._addToCluster.set(e,t)}addToLocations(t){const e=h.findIndexByEndpoint(this._clusterModel.locations,t.endpoint);-1===e?this._clusterModel.locations.push(t):this._clusterModel.locations.splice(e,1)}deleteFromCluster(t){const e=t.endpoint;this._addToCluster.has(e)?this._addToCluster.delete(e):this._deleteFromCluster.set(e,t)}getDeleteFromCluster(){return Array.from(this._deleteFromCluster.values())}getUpdateActions(){const t=Array.from(this._addToCluster.values()).map(t=>t.endpoint),e={addNodes:t,removeNodes:Array.from(this._deleteFromCluster.values()).map(t=>t.endpoint)},s=this.updateClusterConfiguration(t);return s&&(e.clusterConfiguration=s),e}updateClusterConfiguration(t){return this.hasCluster()?null:(this._clusterConfiguration.nodes=t,this._clusterConfiguration.toJSON())}getClusterConfiguration(){return this._clusterConfiguration}restoreFromDeletion(t){this._deleteFromCluster.delete(t.endpoint)}isChanged(){return this._addToCluster.size>0||this._deleteFromCluster.size>0}isPresentInList(t,e){return h.isPresentInList(t,e)}findByEndpoint(t,e){return h.findByEndpoint(t,e)}findIndexByEndpoint(t,e){return h.findIndexByEndpoint(t,e)}hasValidNodesCount(){return this._currentNodesCount>=this.MINIMUM_NODES_REQUIRED}canDeleteNode(){const t=Math.floor(this._clusterModel.nodes.length/2);return this._deleteFromCluster.size<t}hasCluster(){return this._clusterModel.hasCluster}}class l{constructor(t){this._item=t,this._endpoint=t.endpoint,this._isDeleted=!1,this._index=void 0,this._isLocal=!1}getEndPoint(){return this._item.endpoint}getAddress(){return void 0!==this._item._address?this._item._address:void 0!==this._item.rpcAddress?this._item.rpcAddress:null}isNode(){return void 0!==this._item._address}isLocation(){return void 0===this._item._address}getNodeState(){return this.isNode()?this._item._nodeState:null}getIsAvailable(){return this.isNode()?null:this._item.isAvailable}getTerm(){return this.isNode()?this._item.term:null}getSyncStatus(){return this.isNode()?this._item.syncStatus:null}getIsLocal(){return this.isNode()?null:this._item.isLocal}get item(){return this._item}get endpoint(){return this._endpoint}set endpoint(t){return this._endpoint=t}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}get index(){return this._index}set index(t){this._index=t}get isLocal(){return this._isLocal}set isLocal(t){this._isLocal=t}}class u{constructor({electionMinTimeout:t=8e3,electionRangeTimeout:e=6e3,heartbeatInterval:s=2e3,messageSizeKB:i=64,verificationTimeout:r=1500,transactionLogMaximumSizeGB:n=50,batchUpdateInterval:o=5e3,nodes:a=[],secondaryTag:d,primaryNodes:l}={}){this._electionMinTimeout=t,this._electionRangeTimeout=e,this._heartbeatInterval=s,this._messageSizeKB=i,this._verificationTimeout=r,this._transactionLogMaximumSizeGB=n,this._batchUpdateInterval=o,this._nodes=a,this._secondaryTag=d,this._primaryNodes=l}static fromJSON(t){return new u(t)}get electionMinTimeout(){return this._electionMinTimeout}set electionMinTimeout(t){this._electionMinTimeout=t}get electionRangeTimeout(){return this._electionRangeTimeout}set electionRangeTimeout(t){this._electionRangeTimeout=t}get heartbeatInterval(){return this._heartbeatInterval}set heartbeatInterval(t){this._heartbeatInterval=t}get messageSizeKB(){return this._messageSizeKB}set messageSizeKB(t){this._messageSizeKB=t}get verificationTimeout(){return this._verificationTimeout}set verificationTimeout(t){this._verificationTimeout=t}get transactionLogMaximumSizeGB(){return this._transactionLogMaximumSizeGB}set transactionLogMaximumSizeGB(t){this._transactionLogMaximumSizeGB=t}get nodes(){return this._nodes}set nodes(t){this._nodes=t}get batchUpdateInterval(){return this._batchUpdateInterval}set batchUpdateInterval(t){this._batchUpdateInterval=t}get secondaryTag(){return this._secondaryTag}set secondaryTag(t){this._secondaryTag=t}get primaryNodes(){return this._primaryNodes}set primaryNodes(t){this._primaryNodes=t}toJSON(){const t={electionMinTimeout:this._electionMinTimeout,electionRangeTimeout:this._electionRangeTimeout,heartbeatInterval:this._heartbeatInterval,messageSizeKB:this._messageSizeKB,verificationTimeout:this._verificationTimeout,transactionLogMaximumSizeGB:this._transactionLogMaximumSizeGB,batchUpdateInterval:this._batchUpdateInterval,nodes:this._nodes};return void 0!==this._secondaryTag&&(t.secondaryTag=this._secondaryTag),void 0!==this._primaryNodes&&(t.primaryNodes=this._primaryNodes),t}}class h{static isPresentInList(t,e){return t.some(t=>t.endpoint===e)}static findByEndpoint(t,e){return t.find(t=>t.endpoint===e)}static findIndexByEndpoint(t,e){return t.findIndex(t=>t.endpoint===e)}}}}; //# sourceMappingURL=24508.4a8eeb6a881d04747fda.bundle.js.map