Professional Documents
Culture Documents
Dicas Wildfly e Tunning
Dicas Wildfly e Tunning
public class
LoggerProducer
{
@Produces
public LoggerproduceLogger(InjectionPoint
injectionPoint)
{
return
Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
}
Creating
your resource
watches
using
Now that you have learnedthe
basics of
API, we
will illustrate
a
concrete
example;
our
goal will
server resource
(the number
of
JDBC connections for
a
data source)using
pattern to
create your
the
the
detyped
detyped
be
to
active
an
EJB.
API
management
monitor
You
use
can
this
own
server watches
that can
be
integrated
with
environment. This is
shown in
the
following
code snippet:
package
com.packtpub.wflydevelopment.chapter9;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.dmr.ModelNode;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import java.io.Closeable;
import java.net.InetAddress;
import java.util.logging.Level;
import java.util.logging.Logger;
@Stateless
public class WatchMyDB {
private final static Loggerlogger =
Logger.getLogger(WatchMyDB.class.getName());
@Schedule(dayOfWeek
=
*,
minute =
*, second =
your
application
hour
*,
*/30,year
*,
persistent
=
public void
false)
backgroundProcessing()
{
ModelControllerClient
client =
null;
try
{
client =
ModelControllerClient.Factory.create(InetAddress.getByName(localhost),
9990);
final
ModelNode
operation
new
ModelNode();
operation.get(operation).set(read-resource);
operation.get(include-runtime).set(true);
final
ModelNode
address
operation.get(address);
address.add(subsystem,
datasources);
address.add(data-source,
ExampleDS);
address.add(statistics,
pool);
ModelNode
returnVal
ModelNode
node2 =
returnVal.get(result);
final
client.execute(operation);
final
final
String stringActiveCount =
node2.get(ActiveCount).asString();
if
(stringActiveCount.equals(undefined))
return; //
Connection
{
unused
}
int
activeCount
Integer.parseInt(stringActiveCount);
if
(activeCount >
50)
alertAdministrator();
}
logger.log(Level.SEVERE, Exception
!,
}
exc)
closeable)
!=
null)
try
{
{
{
catch (Exception
exc);
}
finally {
safeClose(client);
}
}
public void
safeClose(final
if
Closeable
(closeable
closeable.close();
}
catch (Exception
e)
logger.log(Level.SEVERE, Exception
closingthe
client! ,
e);
}
}
}
private void
alertAdministrator() {
//
Implement
}
}
Criando e-mail
[standalone@192.168.11.109:9990 /] /socket-bindinggroup=standard-sockets/remote-destination-outbound-socketbinding=gmailTest:add(host=smtp.gmail.com,port=993)
[standalone@192.168.11.109:9990 /] /subsystem=mail/mailsession="java:/mail/TestEmailCLI":add(jndi-name="java:/mail/
TestEmailCLI", from="noreply@testegmail.com")
it
$JBOSS_HOME/bin/jconsole.sh
aumentar o nmero de threads
[standalone@192.168.11.244:9990 /] /subsystem=io/
worker=default:write-attribute(name=io-threads,value=45)
(name=task-max-threads, value=45)
Configurar o controle de falha do domnio pgina 51 do wildfly 10
JPA:
@Index(name="index1", columnNames={"column1","column2"})})
@BatchSize(size
=
50)
<property
name="hibernate.default_batch_fetch_size" value="50"
/>
The
The
second-level cache
L2C is
responsible for
caching
entitiesacross persistence contexts
on
the
EntityManagerFactory
level. This is
often known as
the
Entity cache, and
caching
with
L2C is
normally
transparent to
an
application.
This cache is
beneficial
because
it
avoids database
access for
alreadyloaded entitiesand
is
faster for
reading
entitiesthat are
unmodified and
frequently
accessed.
On
the
negative
side, L2C can
be
very memory-consuming for
large amounts
of
objects.
Data can
be
stale for
updated
objects.
Performance can
suffer
significantly depending
on
what locking
mechanism is
used (optimistic/pessimistic).
For
frequent or
concurrently
updated
entities,
L2C scales poorly.
Using L2C in
the
wrong contextmay actually
degrade
performance.
Use
L2C for
critical
read
often, modified
<property
name="hibernate.cache.use_second_level_cache" value="true"/>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
ENABLE_SELECTIVE Enable caching
for
entitiesthat have been
set
with the
@Cacheable annotation.
@NamedQueries({
explicitly
NamedQuery(name =
Customer
c
WHERE
c.name=
:name",hints =
{
value =
"true") }
)
}
)
Query query =
...
query.setHint("org.hibernate.cacheable",
Query caching,
query is
seldom,
using
running
as
with
run
only
caching
a
query
"findCustomersByName",query
@QueryHint( name =
new
"FROM
"org.hibernate.cacheable",
Boolean(true));
all
caching,
a
very few
is
likely to
without
it.
has
a
cost. If
times or
be
more expensive
than
Value
Description
Default
min-pool-size
This
Normal
production
usage
+10-20percent;
in more
extreme
cases, set
it
to
the
value of
maxpool-size
max-poolsize
This
20
Maximum
usage
observed
(in
production
or
relevant
tests)
+10-20percent
specifies
the
minimum
number
of
connections
for
a pool
specifies
the
maximum
number
of
connections
for
a
pool. Note that
there will
probably
be
a
maximum
limit for 20
the
number
of
connections
allowed
by
the
database
value
Performance
recommendation
to
match.
pool-prefill
This
specifies
whether
the
pool
should be
prefilled.
initialpool-size
This
is
the
initial number
of
connections
in
a
pool.
pool-usestrict-min
This
blockingtimeoutwait-millis
This
specifies
whether
the
minpool-size
should
be
considered
strictly.
is
the
maximum
time to
block while
waiting
for
a
connection. Note
that this
timeout
is
only to
apply the
lock
itself. It
will
not
trigger if
creating
a
new
connection
takes a
long time.
allocationretry-waitmillis
This
is
the
time to
wait between
retrying
to
allocate
a
connection.
idletimeoutminutes
This
is
the
maximum
time a
false
true
min-pool-size
false
true
connection
may be
idle before
being closed.
The actual
maximum
time also
depends
on
the
scan time
of
the
IdleRemover
thread, which is
half of
the
smallest
idletimeout-minutes
value of
any
pool.
allocationretry
This
is
the
number
of
allocation
tries that
should be
tried
before throwing
an
exception.
flushstrategy
This
check-validconnectionsql
This
is
the
SQL
statement
to
check
validity
of
a
pool
connection
when
its
fetched
from the
pool.
If
validconnectionchecker-
This is
a
org.jboss.jca.adapters.j
dbc.ValidConnectionC
Used instead of
check-validconnection-sql when
is
the flush FailingConnectionOnly
strategy in
case of the
following errors:
FailingConnectionOnly
IdleConnections
EntirePool
not
not
do
use
needed,
it
class-name
hecker
class
validconnectionchecker-properties
This
use-fastfail
This
backgroundvalidation
This
that is
used for
validating
connection.
is
the
valid
connection
checker
properties.
specifies
whether
connection
allocation
should fail
directly
if
the
first
connection
fetchedis
invalid or
keep
trying until all
connections
in
the
pool are
tried.
the
there is
such
a
database
vendor
implementation
available,
as
it
is
probably
more
efficient
false
a
specifies
whether
connections
should be
validated
in
background
instead of
when they
are
fetched
from the
pool
backgroundvalidationmillis
This
specifies
the
time
between
background
validations.
preparedstatementscache-size
This
is
the
number
of
prepared
false
true
If
connection
validation
is
needed,
doing it
in
the
background is
better than each
time a
connection
is
fetched
statements
per
connection
in
sharepreparedstatements
an
LRU cache.
This
specifies
whether
to
share
prepared
statements,
that is,
false
false
whether
asking
for
the
same
statement
twice without
closinguses the
same
underlying
prepared
statement.
querytimeout
This
helps set
the
query
timeout.
set-txquerytimeout
This
automatically
sets the
query timeout
to
the
time
remaining
until
the
transactions
will timeout
(if
no
transaction
is
active, the
value of
query-timeout
will be
used).
False
spy
This
false
enables
logging
of
SQL
statements.
False
Useful if
set
to
true for
obtaining
and
investigating
the
executed
SQL
statements. Enable
logging
for
org.jboss.jdbc
as
well
transactionisolation
See
information
later in
this
chapter
trackstatements
This
specifies
NOWARN
whether
WildFly
should check
statements
and
result set
closurewhen a
connection
is
returned.
The
possible
values
are:
false (Do not
track)
true (Track and
warn when not
closed)
nowarn
(Track
but
do
not
warn)
False
This
Can
connectionproperties
driver.
specifies
the
properties
that will
be
fed
to
the
JDBC
be
used
to
set
JDBC driverspecific
optimizations
WILDFY CORE IO
The following
table
performance:
explains
the
attributes
and
SESSO
<web-app...>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
</web-app>
OU POR USUARIO
HttpSession session=
request.getSession();
session.setMaxInactiveInterval(20*60);
GZIP-
their
impact on