Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio
Commits
d03d08f1
Commit
d03d08f1
authored
Oct 26, 2016
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicatestorage: add use_bulk option and tests
parent
1ecc04a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
179 additions
and
2 deletions
+179
-2
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+3
-1
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+176
-1
No files found.
src/jio.storage/replicatestorage.js
View file @
d03d08f1
...
@@ -57,6 +57,7 @@
...
@@ -57,6 +57,7 @@
});
});
this
.
_use_remote_post
=
spec
.
use_remote_post
||
false
;
this
.
_use_remote_post
=
spec
.
use_remote_post
||
false
;
this
.
_use_bulk_get
=
spec
.
use_bulk
!==
undefined
?
spec
.
use_bulk
:
true
;
this
.
_conflict_handling
=
spec
.
conflict_handling
||
0
;
this
.
_conflict_handling
=
spec
.
conflict_handling
||
0
;
// 0: no resolution (ie, throw an Error)
// 0: no resolution (ie, throw an Error)
...
@@ -479,7 +480,8 @@
...
@@ -479,7 +480,8 @@
// Keep it like this until the bulk API is stabilized
// Keep it like this until the bulk API is stabilized
var
use_bulk_get
=
false
;
var
use_bulk_get
=
false
;
try
{
try
{
use_bulk_get
=
context
.
_remote_sub_storage
.
hasCapacity
(
"
bulk
"
);
use_bulk_get
=
context
.
_remote_sub_storage
.
hasCapacity
(
"
bulk
"
)
&&
context
.
_use_bulk_get
;
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
!
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
if
(
!
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
501
)))
{
(
error
.
status_code
===
501
)))
{
...
...
test/jio.storage/replicatestorage.tests.js
View file @
d03d08f1
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
equal
(
jio
.
__storage
.
_check_remote_creation
,
true
);
equal
(
jio
.
__storage
.
_check_remote_creation
,
true
);
equal
(
jio
.
__storage
.
_check_remote_deletion
,
true
);
equal
(
jio
.
__storage
.
_check_remote_deletion
,
true
);
equal
(
jio
.
__storage
.
_check_remote_modification
,
true
);
equal
(
jio
.
__storage
.
_check_remote_modification
,
true
);
equal
(
jio
.
__storage
.
_use_bulk_get
,
true
);
equal
(
jio
.
__storage
.
_signature_hash
,
equal
(
jio
.
__storage
.
_signature_hash
,
"
_replicate_7209dfbcaff00f6637f939fdd71fa896793ed385
"
);
"
_replicate_7209dfbcaff00f6637f939fdd71fa896793ed385
"
);
...
@@ -87,7 +88,8 @@
...
@@ -87,7 +88,8 @@
check_local_modification
:
false
,
check_local_modification
:
false
,
check_remote_creation
:
false
,
check_remote_creation
:
false
,
check_remote_deletion
:
false
,
check_remote_deletion
:
false
,
check_remote_modification
:
false
check_remote_modification
:
false
,
use_bulk
:
false
});
});
deepEqual
(
deepEqual
(
...
@@ -102,6 +104,7 @@
...
@@ -102,6 +104,7 @@
equal
(
jio
.
__storage
.
_check_remote_creation
,
false
);
equal
(
jio
.
__storage
.
_check_remote_creation
,
false
);
equal
(
jio
.
__storage
.
_check_remote_deletion
,
false
);
equal
(
jio
.
__storage
.
_check_remote_deletion
,
false
);
equal
(
jio
.
__storage
.
_check_remote_modification
,
false
);
equal
(
jio
.
__storage
.
_check_remote_modification
,
false
);
equal
(
jio
.
__storage
.
_use_bulk_get
,
false
);
equal
(
jio
.
__storage
.
_signature_hash
,
equal
(
jio
.
__storage
.
_signature_hash
,
"
_replicate_11881e431308c0ec8c0e6430be98db380e1b92f8
"
);
"
_replicate_11881e431308c0ec8c0e6430be98db380e1b92f8
"
);
...
@@ -2627,4 +2630,176 @@
...
@@ -2627,4 +2630,176 @@
});
});
});
});
test
(
"
remote document creation with bulk off
"
,
function
()
{
stop
();
expect
(
2
);
var
id
,
post_id
=
"
123456789
"
,
context
=
this
;
function
Storage200Bulk
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
Storage200Bulk
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
bulk
=
function
()
{
throw
new
Error
(
"
Bulk called
"
);
};
Storage200Bulk
.
prototype
.
post
=
function
(
param
)
{
return
this
.
put
(
post_id
,
param
);
};
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
return
this
.
_sub_storage
.
buildQuery
.
apply
(
this
.
_sub_storage
,
arguments
);
};
jIO
.
addStorage
(
'
replicatestorage200nobulk
'
,
Storage200Bulk
);
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
memory
"
},
remote_sub_storage
:
{
type
:
"
replicatestorage200nobulk
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
use_bulk
:
false
});
context
.
jio
.
__storage
.
_remote_sub_storage
.
post
({
"
title
"
:
"
bar
"
})
.
then
(
function
(
result
)
{
id
=
result
;
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
6799f3ea80e325b89f19589282a343c376c1f1af
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
remote document modification with bulk off
"
,
function
()
{
stop
();
expect
(
3
);
var
id
,
post_id
=
"
123456789
"
,
context
=
this
;
function
Storage200Bulk
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
Storage200Bulk
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
bulk
=
function
()
{
throw
new
Error
(
"
bulk called
"
);
};
Storage200Bulk
.
prototype
.
post
=
function
(
param
)
{
return
this
.
put
(
post_id
,
param
);
};
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
return
this
.
_sub_storage
.
buildQuery
.
apply
(
this
.
_sub_storage
,
arguments
);
};
jIO
.
addStorage
(
'
replicatestorage200nobulkremotemodification
'
,
Storage200Bulk
);
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
memory
"
},
remote_sub_storage
:
{
type
:
"
replicatestorage200nobulkremotemodification
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
use_bulk
:
false
});
context
.
jio
.
__storage
.
_remote_sub_storage
.
post
({
"
title
"
:
"
bar
"
})
.
then
(
function
(
result
)
{
id
=
result
;
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
6799f3ea80e325b89f19589282a343c376c1f1af
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_remote_sub_storage
.
put
(
id
,
{
"
title
"
:
"
foo
"
}
);
})
.
then
(
function
(
result
)
{
id
=
result
;
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
foo
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
}(
jIO
,
QUnit
));
}(
jIO
,
QUnit
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment