Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Stefane Fermigier
jio
Commits
a6e2e877
Commit
a6e2e877
authored
Jan 13, 2017
by
Hardik Juneja
Committed by
Romain Courteaud
Jan 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the 'bulk_get' capacity.
It allow to check recursively if a storage support bulk.
parent
8a170cab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
4 deletions
+120
-4
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+1
-1
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+1
-1
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+118
-2
No files found.
src/jio.storage/erp5storage.js
View file @
a6e2e877
...
...
@@ -447,7 +447,7 @@
ERP5Storage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
((
name
===
"
list
"
)
||
(
name
===
"
query
"
)
||
(
name
===
"
select
"
)
||
(
name
===
"
limit
"
)
||
(
name
===
"
sort
"
));
(
name
===
"
sort
"
))
||
(
name
===
"
bulk_get
"
)
;
};
function
isSingleLocalRoles
(
parsed_query
)
{
...
...
src/jio.storage/replicatestorage.js
View file @
a6e2e877
...
...
@@ -526,7 +526,7 @@
// Keep it like this until the bulk API is stabilized
var
use_bulk_get
=
false
;
try
{
use_bulk_get
=
context
.
_remote_sub_storage
.
hasCapacity
(
"
bulk
"
);
use_bulk_get
=
context
.
_remote_sub_storage
.
hasCapacity
(
"
bulk
_get
"
);
}
catch
(
error
)
{
if
(
!
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
501
)))
{
...
...
test/jio.storage/replicatestorage.tests.js
View file @
a6e2e877
...
...
@@ -3658,7 +3658,10 @@
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
Storage200Bulk
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
bulk_get
"
)
{
return
true
;
}
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
...
...
@@ -3738,7 +3741,10 @@
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
Storage200Bulk
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
bulk_get
"
)
{
return
true
;
}
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
...
...
@@ -3809,4 +3815,114 @@
});
});
test
(
"
Donot bulk if substorage don't implement it
"
,
function
()
{
stop
();
expect
(
2
);
var
id
,
post_id
=
"
123456789
"
,
context
=
this
;
function
SubStorage200Bulk
()
{
return
;
}
function
Storage200Bulk
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
Storage200Bulk
.
prototype
.
bulk
=
function
(
args
)
{
deepEqual
(
args
,
[{
method
:
"
get
"
,
parameter_list
:
[
post_id
]
}]);
return
this
.
_sub_storage
.
bulk
(
args
);
};
Storage200Bulk
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
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
);
SubStorage200Bulk
.
prototype
.
get
=
function
()
{
return
{
title
:
"
bar
"
};
};
SubStorage200Bulk
.
prototype
.
post
=
function
(
param
)
{
return
this
.
put
(
post_id
,
param
);
};
SubStorage200Bulk
.
prototype
.
put
=
function
()
{
return
post_id
;
};
SubStorage200Bulk
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
bulk_get
"
)
{
return
false
;
}
return
true
;
};
SubStorage200Bulk
.
prototype
.
buildQuery
=
function
()
{
return
[{
id
:
"
123456789
"
,
value
:
{
"
title
"
:
"
bar
"
}}];
};
jIO
.
addStorage
(
'
replicatesubstorage200nobulk
'
,
SubStorage200Bulk
);
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
memory
"
},
remote_sub_storage
:
{
type
:
"
replicatestorage200nobulk
"
,
sub_storage
:
{
type
:
"
replicatesubstorage200nobulk
"
}
}
});
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
();
});
});
}(
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