use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class FBMaintenanceManager method shutdownDatabase.
// ----------- Database Shutdown -------------------
public void shutdownDatabase(int shutdownMode, int timeout) throws SQLException {
if (shutdownMode != SHUTDOWN_ATTACH && shutdownMode != SHUTDOWN_TRANSACTIONAL && shutdownMode != SHUTDOWN_FORCE) {
throw new IllegalArgumentException("Shutdown mode must be " + "one of: SHUTDOWN_ATTACH, SHUTDOWN_TRANSACTIONAL, SHUTDOWN_FORCE");
}
if (timeout < 0) {
throw new IllegalArgumentException("Timeout must be >= 0");
}
try (FbService service = attachServiceManager()) {
ServiceRequestBuffer srb = createDefaultPropertiesSRB(service);
srb.addArgument(shutdownMode, timeout);
executeServicesOperation(service, srb);
}
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class FBMaintenanceManager method setPageFill.
public void setPageFill(int pageFill) throws SQLException {
if (pageFill != PAGE_FILL_FULL && pageFill != PAGE_FILL_RESERVE) {
throw new IllegalArgumentException("Page fill must be either PAGE_FILL_FULL or PAGE_FILL_RESERVE");
}
try (FbService service = attachServiceManager()) {
ServiceRequestBuffer srb = createDefaultPropertiesSRB(service);
srb.addArgument(isc_spb_prp_reserve_space, (byte) pageFill);
executeServicesOperation(service, srb);
}
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class FBBackupManagerBase method getBackupSRB.
/**
* Creates and returns the "backup" service request buffer for the Service Manager.
*
* @param service
* Service handle
* @param options
* The isc_spb_bkp_* parameters options to be used
* @return the "backup" service request buffer for the Service Manager.
*/
protected ServiceRequestBuffer getBackupSRB(FbService service, int options) throws SQLException {
ServiceRequestBuffer backupSPB = service.createServiceRequestBuffer();
backupSPB.addArgument(isc_action_svc_backup);
backupSPB.addArgument(SpbItems.isc_spb_dbname, getDatabase());
addBackupsToBackupRequestBuffer(service, backupSPB);
if (verboseBackup()) {
backupSPB.addArgument(SpbItems.isc_spb_verbose);
}
backupSPB.addArgument(SpbItems.isc_spb_options, options);
return backupSPB;
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class FBBackupManagerBase method getRestoreSRB.
/**
* Creates and returns the "backup" service request buffer for the Service Manager.
*
* @param service
* Service handle
* @param options
* The options to be used for the backup operation
* @return the "backup" service request buffer for the Service Manager.
*/
protected ServiceRequestBuffer getRestoreSRB(FbService service, int options) {
ServiceRequestBuffer restoreSPB = service.createServiceRequestBuffer();
restoreSPB.addArgument(isc_action_svc_restore);
// restore files with sizes except the last one
for (Iterator<PathSizeStruct> iter = restorePaths.iterator(); iter.hasNext(); ) {
PathSizeStruct pathSize = iter.next();
restoreSPB.addArgument(SpbItems.isc_spb_dbname, pathSize.getPath());
if (iter.hasNext() && pathSize.getSize() != -1) {
restoreSPB.addArgument(isc_spb_res_length, pathSize.getSize());
}
}
addBackupsToRestoreRequestBuffer(service, restoreSPB);
if (restoreBufferCount != -1) {
restoreSPB.addArgument(isc_spb_res_buffers, restoreBufferCount);
}
if (restorePageSize != -1) {
restoreSPB.addArgument(isc_spb_res_page_size, restorePageSize);
}
restoreSPB.addArgument(isc_spb_res_access_mode, (byte) (restoreReadOnly ? isc_spb_res_am_readonly : isc_spb_res_am_readwrite));
if (verbose) {
restoreSPB.addArgument(SpbItems.isc_spb_verbose);
}
if ((options & RESTORE_CREATE) != RESTORE_CREATE && (options & RESTORE_REPLACE) != RESTORE_REPLACE) {
options |= restoreReplace ? RESTORE_REPLACE : RESTORE_CREATE;
}
restoreSPB.addArgument(SpbItems.isc_spb_options, options);
return restoreSPB;
}
use of org.firebirdsql.gds.ServiceRequestBuffer in project jaybird by FirebirdSQL.
the class TestJaybirdBlobBackupProblem method queryService.
private void queryService(FbService service, String outputFilename) throws Exception {
ServiceRequestBuffer serviceRequestBuffer = service.createServiceRequestBuffer();
serviceRequestBuffer.addArgument(ISCConstants.isc_info_svc_to_eof);
final StringBuilder stringBuffer = new StringBuilder();
boolean finished = false;
try (FileOutputStream file = new FileOutputStream(outputFilename)) {
while (!finished) {
byte[] buffer = service.getServiceInfo(null, serviceRequestBuffer, 1024);
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
// TODO Find out why unused
final byte firstByte = (byte) byteArrayInputStream.read();
int numberOfBytes = (short) ((byteArrayInputStream.read()) + (byteArrayInputStream.read() << 8));
if (numberOfBytes == 0) {
if (byteArrayInputStream.read() != ISCConstants.isc_info_end)
throw new Exception("Expect ISCConstants.isc_info_end here");
finished = true;
} else {
for (; numberOfBytes >= 0; numberOfBytes--) {
final byte byteToWrite = (byte) byteArrayInputStream.read();
file.write(byteToWrite);
stringBuffer.append((char) byteToWrite);
}
}
}
}
assertTrue("Looks like the backup failed. See logfile " + outputFilename, stringBuffer.toString().contains("committing, and finishing."));
}
Aggregations