funambol - 연락처 형식 해석 최적화
(1) 테스트 동시 다발 인원: 20 명 (집합 점 이 있 음) (2) 업무 수행 에 대한 사고 시간: 1s
(3) 하나의 사무 에는 네 번 의 요청 이 포함 되 어 있 습 니 다. (완전한 동기 화 과정)
(4) 지속 시간: 30 분
(5) 연락처 수: 350
(6) 하드웨어 환경 (가상 컴퓨터):
CentOS 5 (2.6.18 - 164. el5 커 널)
4G 메모리
쌍 핵 CPU
테스트 결과
top 서버 상태 관찰:
vcard:60%-80%
json:20%-30%
protobuf: 7% - 10% (protobuf 가 문자열 로 변 환 된 후 특수 문자 이기 때문에,
xml 에서 해석 할 수 없 기 때문에 base 64 의 디 코딩 을 추가 합 니 다.
데이터 전송 도 많이 줄어든다)
최적화
json 에 대해 서 는 JSONarray 의 문자열 형식 으로 전송 하면 됩 니 다.
protobuf 에 대해 서 는 자신의 proto 파일 을 정의 해 야 합 니 다. 다음 과 같 습 니 다.
// See README.txt for information and build instructions.
package com.test.pim.common;
option java_package = "com.test.pim.common";
option java_outer_classname = "ContactProtos";
message Contact {
optional Name name = 1;
optional Organization org = 2;
repeated PhoneEntry phones = 3;
repeated EmailEntry emails = 4;
repeated WebPageEntry webpages = 5;
repeated AddressEntry addresses = 6;
repeated OnlineMessageEntry onlineMessages = 7;
repeated string groups = 8;
repeated string notes = 9;
optional string birthday = 10;
//Name Definition
message Name {
optional string firstName = 1;
optional string middleName = 2;
optional string lastName = 3;
optional string suffix = 4;
optional string prefix = 5;
optional string nickName = 6;
}
//Organization Definition
message Organization {
optional string company = 1;
optional string department = 2;
optional string jobTitle = 3;
}
//Phone Definition
message PhoneEntry {
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
WORKFAX = 3;
HOMEFAX = 4;
OTHERFAX = 5;
OTHER = 6;
CAR = 7;
ISDN = 8;
CUSTOM = 9;
}
optional string label = 1;
required PhoneType type = 2 [default = MOBILE];
required string value = 3;
}
//Email Definition
message EmailEntry {
enum EmailType {
HOME = 0;
WORK = 1;
OTHER = 2;
CUSTOM = 3;
}
optional string label = 1;
required EmailType type = 2 [default = HOME];
required string value = 3;
}
//WebPage Definition
message WebPageEntry {
enum WebPageType {
HOME = 0;
BLOG = 1;
WORK = 2;
OTHER = 3;
CUSTOM = 4;
}
optional string label = 1;
required WebPageType type = 2 [default = HOME];
required string value = 3;
}
//Address Definition
message AddressEntry {
enum AddressType {
HOME = 0;
WORK = 1;
OTHER = 2;
CUSTOM = 3;
}
optional string label = 1;
required AddressType type = 2 [default = HOME];
required AddressExtend value = 3;
}
message AddressExtend {
optional string street = 1;
optional string city = 2;
optional string state = 3;
optional string postcode = 4;
optional string country = 5;
}
//OnlineMessage Definition
message OnlineMessageEntry {
enum OnlineMessageType {
QQ = 0;
MSN = 1;
SKYPE = 2;
GOOGLETALK = 3;
AIM = 4;
YAHOO = 5;
ICQ = 6;
JABBER = 7;
}
optional string label = 1;
required OnlineMessageType type = 2 [default = QQ];
required string value = 3;
}
}
데이터 구조 전송 코드:
ContactProtos.Contact.Builder contact =
ContactProtos.Contact.newBuilder();
contact.setName(ContactProtos.Contact.Name.newBuilder().setLastName("testProtobuf").build());
contact.addPhones(ContactProtos.Contact.PhoneEntry.newBuilder().setType(ContactProtos.Contact.PhoneEntry.PhoneType.HOME)
.setValue("425900").build());
contact.addPhones(ContactProtos.Contact.PhoneEntry.newBuilder().setType(ContactProtos.Contact.PhoneEntry.PhoneType.MOBILE)
.setValue("13163209158").build());
byte[] encode = Base64.encode(contact.build().toByteArray());
xml.append(new String(encode, "UTF-8"));
서버 분석 코드:
ContactProtos.Contact c = ContactProtos.Contact.parseFrom(Base64.decode(data.getData().getBytes("UTF-8")));
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
콘텐츠 SaaS | JSON 스키마 양식 빌더Bloomreach Content를 위한 JSON Form Builder 맞춤형 통합을 개발합니다. 최근 Bloomreach Content SaaS는 내장 앱 프레임워크를 사용하여 혁신적인 콘텐츠 유형 필드를 구축할...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.