Home > database >  Younger brother for a great god, and directing a centos7.0 take pictures on ali cloud server 250 KB
Younger brother for a great god, and directing a centos7.0 take pictures on ali cloud server 250 KB

Time:09-30


Mongo version is 3.4.7

Using GridFS access picture

The code below

 
/* *
* save the file
* @ param collectionName
* @ param mongoFile
*/
Public Boolean saveFiles (String collectionName, MongoFile MongoFile) {
Try {
//DB DB=mongoTemplate. GetDb ();
//DBCollection mongdb_pic=the getCollection (collectionName);
//DBObject DBObject=new BasicDBObject ();
//if (mongoFile getFile ()!=null) {
.//byte [] bytes=FileUtil file2byte (mongoFile. GetFile ());
//
//Binary Binary=new Binary (bytes);
//dbObject. Put (" imgByte, "binary);
//}
//dbObject. Put (" id ", mongoFile getId ());
//dbObject. Put (" fileName ", mongoFile getFileName ());
//dbObject. Put (" fileSize, mongoFile getFileSize ());
//dbObject. Put (" descs ", mongoFile getDescs ());
//dbObject. Put (" fileType, mongoFile getFileType ());
//dbObject. Put (" contentType ", mongoFile getContentType ());
//dbObject. Put (" oldName ", mongoFile getContentType ());
//mongdb_pic. Save (dbObject);

The DB DB=mongoTemplate. GetDb ();
The GridFS GridFS=new GridFS (db, collectionName);
GridFSInputFile GFS=gridFS. CreateFile (mongoFile getFile ());
System. The out. Println (" file size: "+ mongoFile. GetFile (). The length ());
GFS. SetChunkSize (mongoFile. GetFile (). The length ());
GFS. SetFilename (mongoFile getFileName ());
GFS. Put (" _id ", mongoFile getId ());
GFS. Put (" fileName ", mongoFile getFileName ());
GFS. Put (" fileSize, "mongoFile getFileSize ());
GFS. Put (" descs ", mongoFile getDescs ());
GFS. Put (" fileType, "mongoFile getFileType ());
GFS. Put (" contentType, "mongoFile getContentType ());
GFS. Put (" oldName ", mongoFile getOldFileName ());
GFS. The save ();
} the catch (Exception e) {
Data logger. The error (" Mongo operation & gt;> Storing files sent wrong & gt;> Error: "+ e. oString ());
e.printStackTrace();
return false;
}
return true;
}

/* *
* the query file
* @ param collectionName
* @ param filename
* @ return
*/
Public GridFSDBFile retrieveFileOne (String collectionName, String filename) {
Try {
The DB DB=mongoTemplate. GetDb ();
The GridFS GridFS=new GridFS (db, collectionName);
GridFSDBFile dbfile=gridFS. FindOne (filename);
If (dbfile!=null) {
Return dbfile;
}
} the catch (Exception e) {
Data logger. The error (" Mongo operation & gt;> Get the error to the file & gt;> Error: "+ e. oString ());
e.printStackTrace();
}
return null;
}


CodePudding user response:

Use mongofiles to see how long will take picture when

CodePudding user response:

reference 1st floor rucypli response:
use mongofiles to see how long will take picture when


how to take pictures of time
./mongofiles -d preFileDb get "1. JPG"
How to display the execution time

CodePudding user response:

reference 1st floor rucypli response:
use mongofiles to see how long will take picture when


Take pictures 877 KB silently and calculated that about four seconds, this is why ah, don't understand,

CodePudding user response:

refer to the second floor javalearnNet response:
Quote: refer to 1st floor rucypli response:

Use mongofiles to see how long will take picture when


how to take pictures of time
./mongofiles -d preFileDb get "1. JPG"
How to display the execution time

Time./mongofiles - d preFileDb get "1. JPG"

CodePudding user response:

reference javalearnNet reply: 3/f
Quote: refer to 1st floor rucypli response:

Use mongofiles to see how long will take picture when


Take pictures 877 KB silently and calculated that about four seconds, this is why ah, don't understand.

Perform a few times try there may not be cached in memory

CodePudding user response:

reference 5 floor rucypli reply:
Quote: refer to the third floor javalearnNet response:

Quote: refer to 1st floor rucypli response:

Use mongofiles to see how long will take picture when


Take pictures 877 KB silently and calculated that about four seconds, this is why ah, don't understand.

Perform a few times may not be cached in memory test under


Perform a lot of times, is also a ali cloud server, on my own server, memory of 4 g, execute the same command also soon, in the company is very slow, this is why, with numa

CodePudding user response:

Start the mongo I also perform numactl - interleave=all, didn't take effect? This is, strange, development environment, test environment, production environment has a problem,

CodePudding user response:

Another direct access to the cloud disk high availability of this method is not recommended because there is no mechanism

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related