void ConnSettings::changeConnParameters(QString s)
{
    QString _name = getIconName(s);
    Transports->setEnabled(true);
    Path->setPlaceholderText("[path]");
    Path->setEnabled(true);
    if ( _name=="qemu" ) {
        Path->setText( (s.endsWith("session"))?"session":"system" );
        Path->setEnabled(false);
    } else if ( _name=="vbox" ) {
        Path->setText( "session" );
        Path->setEnabled(false);
    } else if ( _name=="vmware" ) {
        if ( getDriverName(s).startsWith("vmware") ) {
            // VMware Player/Workstation
            Path->setText( "session" );
            Path->setEnabled(false);
        } else {
            // VMware ESX
            Transports->setCurrentIndex(0);
            Transports->setEnabled(false);
            Path->setPlaceholderText(
                        "[[folder/...]datacenter/[folder/...][cluster/]server]");
            Path->clear();
        };
    } else if ( _name=="openvz" ) {
        Path->setText( "system" );
        Path->setEnabled(false);
    } else if ( getDriverName(s)=="test" ) {
        Path->setText( "default" );
    } else Path->clear();
}
示例#2
0
int ManagedDatasource::grabLock(ExceptionSink *xsink) {
   if (grabLockIntern() < 0) {
      endDBActionIntern();
      const char *un = getUsername();
      const char *db = getDBName();
      xsink->raiseException("TRANSACTION-LOCK-TIMEOUT", "%s:%s@%s: TID %d timed out on datasource '%s@%s' after waiting %d millisecond%s on transaction lock held by TID %d",
			    getDriverName(), getUsernameStr().c_str(), getDBNameStr().c_str(), 
			    gettid(), un ? un : "<n/a>", db ? db : "<n/a>", tl_timeout_ms, 
			    tl_timeout_ms == 1 ? "" : "s", tid);
      return -1;
   }
   return 0;
}
void ConnSettings::initParamLayout()
{
    connName = new QLabel("Connection:", this);
    ConnName = new QLineEdit(this);
    ConnName->setPlaceholderText("Enter Connection Name");
    connect(ConnName, SIGNAL(textChanged(QString)),
            this, SLOT(set_Title_Name(QString)));
    driver = new QLabel("Driver:", this);
    Drivers = new QComboBox(this);
    Drivers->addItems(HV_DRIVERS);
    for (int i=0; i<Drivers->count(); i++) {
        QString _text =  Drivers->itemText(i);
        QIcon _icon = QIcon::fromTheme( getIconName( _text ) );
        Drivers->setItemIcon(i, _icon);
        Drivers->setItemData(i, getDriverName( _text ));
    };
    connect(Drivers, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(changeConnParameters(QString)));
    transport = new QLabel("Transport:", this);
    Transports = new QComboBox(this);
    Transports->addItems(TRANSPORTS);
    for (int i=0; i<Transports->count(); i++) {
        QString _text =  Transports->itemText(i);
        if ( _text.contains("--") ) _text.clear();
        Transports->setItemData(i, _text.toLower() );
    };
    host = new QLabel("Host:", this);
    Host = new QLineEdit(this);
    Host->setPlaceholderText("[username@][hostname][:port]");
    path = new QLabel("Path:", this);
    Path = new QLineEdit(this);
    Path->setPlaceholderText("[path]");
    extra = new QLabel("Extra:", this);
    Extra = new QLineEdit(this);
    Extra->setPlaceholderText("[?extraparameters]");
    paramLayout = new QGridLayout();
    paramLayout->addWidget(connName, 0, 0);
    paramLayout->addWidget(ConnName, 0, 1);
    paramLayout->addWidget(driver, 1, 0);
    paramLayout->addWidget(Drivers, 1, 1);
    paramLayout->addWidget(transport, 2, 0);
    paramLayout->addWidget(Transports, 2, 1);
    paramLayout->addWidget(host, 3, 0);
    paramLayout->addWidget(Host, 3, 1);
    paramLayout->addWidget(path, 4, 0);
    paramLayout->addWidget(Path, 4, 1);
    paramLayout->addWidget(extra, 5, 0);
    paramLayout->addWidget(Extra, 5, 1);
    parameters = new QWidget(this);
    parameters->setLayout(paramLayout);
}
示例#4
0
void ManagedDatasource::destructor(ExceptionSink *xsink) {
   AutoLocker al(&ds_lock);
   if (tid == gettid() || tid == -1)
      // closeUnlocked will throw an exception if a transaction is in progress (and release the transaction lock if held)
      closeUnlocked(xsink);
   else
      xsink->raiseException("DATASOURCE-ERROR", "%s:%s@%s: TID %d deleted Datasource while TID %d is holding the transaction lock", getDriverName(), getUsernameStr().c_str(), getDBNameStr().c_str(), gettid(), tid);
}
示例#5
0
void ManagedDatasource::cleanup(ExceptionSink *xsink) {
   // this thread has the transaction lock
   AutoLocker al(&ds_lock);
   assert(isInTransaction());

   xsink->raiseException("DATASOURCE-TRANSACTION-EXCEPTION", "%s:%s@%s: TID %d terminated while in a transaction; transaction will be automatically rolled back and the lock released", getDriverName(), getUsernameStr().c_str(), getDBNameStr().c_str(), gettid());
   Datasource::rollback(xsink);
   setTransactionStatus(false);
   releaseLockIntern();
}
示例#6
0
// returns 0 for OK, -1 for exception
int ManagedDatasource::closeUnlocked(ExceptionSink *xsink) {
   int rc = 0;

   if (grabLock(xsink))
      return -1;

   if (isOpen()) {
      if (isInTransaction()) {
	 if (!wasConnectionAborted()) {
	    // FIXME: check for statement
	    xsink->raiseException("DATASOURCE-TRANSACTION-EXCEPTION", "%s:%s@%s: Datasource closed while in a transaction; transaction will be automatically rolled back and the lock released", getDriverName(), getUsernameStr().c_str(), getDBNameStr().c_str());
	    Datasource::rollback(xsink);
	 }
	 remove_thread_resource(this);
	 setTransactionStatus(false);
	 // force-exit the transaction lock
	 forceReleaseLockIntern();
	 rc = -1;
      }

      Datasource::close();
   }
   
   return rc;
}
示例#7
0
int Datasource::beginImplicitTransaction(ExceptionSink* xsink) {
   //printd(5, "Datasource::beginImplicitTransaction() autocommit=%s\n", autocommit ? "true" : "false");
   if (priv->autocommit) {
      xsink->raiseException("AUTOCOMMIT-ERROR", "%s:%s@%s: transaction management is not available because autocommit is enabled for this Datasource", getDriverName(), priv->username.c_str(), priv->dbname.c_str());
      return -1;
   }
   return qore_dbi_private::get(*priv->dsl)->beginTransaction(this, xsink);
}