|
CS 580 Client-Server Programming
Fall Semester, 2000
Concurrent Server Issues
|
|
|
Previous   
Lecture Notes Index
   Next    
© 2000, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 02-Oct-00
|
|
Contents of Doc 10, Concurrent Server Issues
References
Client-Server
Software Testing on the Desktop and the Web, Mosley, Prentice Hall, 2000
Previous
SDSU Client-Server Programming lecture notes
SDSU
Java library
Concurrent
Server Issues
Issues:
- Separation
of responsibilities
- Testing
- Logging
- Configuration
- Thread
management
- Error
handling
Separation
of Responsibilities
Decompose
server into parts
Separate
parts:
- Are
easier to build/debug/test
Testing
Testing
is important because:
- Client-servers
are complex
- Servers
tend to be mission critical
Some
testers claim client-server projects require one tester per programmer
Why
logging?
- Performance
tuning
- Upgrade
justification
- Problem
tracking
- Access
counting
What
should be logged?
Normally
a log entry contains several pieces of information:
- Date
and time
- Service
that caused the entry
- Client
address that caused the entry
- Host
on which the server runs
- Event
How
should clients and servers log?
Basic
choices:
- Appending
to a log file
- System
logging facility
Simple
appending problems
This
simplistic approach can cause problems with the following:
- Concurrency:
Two server processes or threads writing to the same logfile
- Performance:
Every log entry requires lots of overhead (opening and closing the logfile)
Some
solutions:
- Rely
on the OS to perform atomic appends to the log file. (One unbuffered write per
log entry)
- Do
all logging in the parent process or a dedicated logging thread (Keep the log
file open)
- Synchronize
the writing to the log file.
SDSU
Logger
import sdsu.logging.*;
public class LoggingExample
{
public static void main(String[] args ) throws LoggerCreationException {
FileLogger.register( "MyLog");
LoggingExample test = new LoggingExample();
test.bar();
test.foo();
}
public void foo() {
Logger.log( "foo called");
}
public void bar(){
try {
Logger.log( "bar called");
int a = 1;
int b = 0;
int c = a/b;
}
catch (Exception error ) {
Logger.error( "Error in bar");
Logger.error( error);
}
}
}
MyLog.log
contents
time='2:47:57 PM';date=10/2/00;type=Log;message='bar called';
time='2:47:57 PM';date=10/2/00;type=Error;message='Error in bar';
time='2:47:57 PM';date=10/2/00;type=Error;message='java.lang.ArithmeticException: / by zero';
time='2:47:57 PM';date=10/2/00;type=Log;message='foo called';
Types
of Loggers
FileLogger
- Sends log messages to file
NullLogger
- Ignores log messages
ScreenLogger
- Sends log messages to screen
SelectiveLogger
- allows you to turn off types of messages
Types
of Log messages
debug
error
log
warning
Debug
Class
Allows
debug states to be turned off/on
Debug
messages contain line number if JIT is off
Output
can be sent to file or screen
Configuration
Servers
are complex
Difference
sites/customers require different settings
Commercial
clients and servers are configurable
Error
Handling
Servers
should not crash or stop operating
Thread
Management
Maintain
a pool of thread to handle
Several
ways to hand set of threads:
- Thread
factory
- Ask
factory for thread
- Factory
contains a list of threads ready for use
- Thread
pool
Copyright ©, All rights reserved.
2000 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.
Previous   
visitors since 02-Oct-00
   Next