Replace anyjson with oslo.serialization

Now, when we started to use oslo.serialization it is safe
to replace all the usages of anyjson with jsonutils from
oslo library.
oslo.serialization uses anyjson under the hood, so there
shouldn't be any performance changes.

Change-Id: I8d6fbfbf88e657f5586c7361de849683c064d2e2
This commit is contained in:
Ruslan Kamaldinov 2014-12-13 18:05:15 +03:00
parent 8480bac9b9
commit 734d407332
5 changed files with 9 additions and 10 deletions

View File

@ -15,10 +15,10 @@
import uuid import uuid
import anyjson
import eventlet.debug import eventlet.debug
from oslo import messaging from oslo import messaging
from oslo.messaging import target from oslo.messaging import target
from oslo.serialization import jsonutils
from murano.common import config from murano.common import config
from murano.common.helpers import token_sanitizer from murano.common.helpers import token_sanitizer
@ -48,7 +48,7 @@ class TaskProcessingEndpoint(object):
def handle_task(context, task): def handle_task(context, task):
s_task = token_sanitizer.TokenSanitizer().sanitize(task) s_task = token_sanitizer.TokenSanitizer().sanitize(task)
LOG.info(_('Starting processing task: {task_desc}').format( LOG.info(_('Starting processing task: {task_desc}').format(
task_desc=anyjson.dumps(s_task))) task_desc=jsonutils.dumps(s_task)))
result = task['model'] result = task['model']
try: try:

View File

@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import anyjson
import logging import logging
from oslo.serialization import jsonutils
log = logging.getLogger("murano-common.messaging") log = logging.getLogger("murano-common.messaging")
@ -28,7 +28,7 @@ class Message(object):
message_handle.properties.get('message_id') message_handle.properties.get('message_id')
try: try:
self.body = None if message_handle is None else \ self.body = None if message_handle is None else \
anyjson.loads(message_handle.body) jsonutils.loads(message_handle.body)
except ValueError as e: except ValueError as e:
self.body = None self.body = None
log.exception(e) log.exception(e)

View File

@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import anyjson
import logging import logging
import ssl as ssl_module import ssl as ssl_module
from eventlet import patcher from eventlet import patcher
kombu = patcher.import_patched('kombu') kombu = patcher.import_patched('kombu')
from oslo.serialization import jsonutils
from subscription import Subscription from subscription import Subscription
@ -95,7 +95,7 @@ class MqClient(object):
producer.publish( producer.publish(
exchange=str(exchange), exchange=str(exchange),
routing_key=str(key), routing_key=str(key),
body=anyjson.dumps(message.body), body=jsonutils.dumps(message.body),
message_id=str(message.id) message_id=str(message.id)
) )

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import anyjson from oslo.serialization import jsonutils
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.dialects import mysql from sqlalchemy.dialects import mysql
@ -23,9 +23,9 @@ class JsonBlob(sa.TypeDecorator):
impl = sa.Text impl = sa.Text
def process_bind_param(self, value, dialect): def process_bind_param(self, value, dialect):
return anyjson.serialize(value) return jsonutils.dumps(value)
def process_result_value(self, value, dialect): def process_result_value(self, value, dialect):
if value is not None: if value is not None:
return anyjson.deserialize(value) return jsonutils.loads(value)
return None return None

View File

@ -5,7 +5,6 @@ pbr>=0.6,!=0.7,<1.0
Babel>=1.3 Babel>=1.3
SQLAlchemy>=0.8.4,<=0.8.99,>=0.9.7,<=0.9.99 SQLAlchemy>=0.8.4,<=0.8.99,>=0.9.7,<=0.9.99
alembic>=0.6.4 alembic>=0.6.4
anyjson>=0.3.3
eventlet>=0.15.2 eventlet>=0.15.2
PasteDeploy>=1.5.0 PasteDeploy>=1.5.0
Routes>=1.12.3,!=2.0 Routes>=1.12.3,!=2.0